WebCore:
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Oct 2008 02:33:16 +0000 (02:33 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Oct 2008 02:33:16 +0000 (02:33 +0000)
2008-10-09  David Hyatt  <hyatt@apple.com>

        https://bugs.webkit.org/show_bug.cgi?id=21446

        This patch gets CSS scrollbars up and limping.  There's no way to distinguish between states or between
        orientation and back vs. forward on the buttons, but it's a start.

        Reviewed by Oliver Hunt

        Added scrollbars/basic-scrollbar.html

        * WebCore.xcodeproj/project.pbxproj:
        * css/CSSSelector.cpp:
        (WebCore::CSSSelector::extractPseudoType):
        * css/CSSSelector.h:
        (WebCore::CSSSelector::):
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
        * platform/ScrollTypes.h:
        (WebCore::):
        * platform/Scrollbar.h:
        (WebCore::Scrollbar::styleChanged):
        * platform/ScrollbarThemeComposite.cpp:
        (WebCore::ScrollbarThemeComposite::paint):
        (WebCore::ScrollbarThemeComposite::splitTrack):
        * platform/ScrollbarThemeComposite.h:
        (WebCore::ScrollbarThemeComposite::paintScrollbarBackground):
        (WebCore::ScrollbarThemeComposite::paintTrackBackground):
        (WebCore::ScrollbarThemeComposite::paintTrackPiece):
        * platform/win/ScrollbarThemeSafari.cpp:
        (WebCore::ScrollbarThemeSafari::paintTrackBackground):
        * platform/win/ScrollbarThemeSafari.h:
        * platform/win/ScrollbarThemeWin.cpp:
        (WebCore::ScrollbarThemeWin::paintTrack):
        * platform/win/ScrollbarThemeWin.h:
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::createScrollbar):
        (WebCore::RenderLayer::styleChanged):
        * rendering/RenderScrollbar.cpp: Added.
        (WebCore::RenderScrollbar::createCustomScrollbar):
        (WebCore::RenderScrollbar::RenderScrollbar):
        (WebCore::RenderScrollbar::~RenderScrollbar):
        (WebCore::RenderScrollbar::getScrollbarPseudoStyle):
        (WebCore::RenderScrollbar::updateScrollbarParts):
        (WebCore::RenderScrollbar::updateScrollbarPart):
        (WebCore::RenderScrollbar::paintPart):
        (WebCore::RenderScrollbar::buttonRect):
        (WebCore::RenderScrollbar::minimumThumbLength):
        * rendering/RenderScrollbar.h: Added.
        (WebCore::RenderScrollbar::styleChanged):
        (WebCore::RenderScrollbar::owningRenderer):
        * rendering/RenderScrollbarPart.cpp: Added.
        (WebCore::RenderScrollbarPart::RenderScrollbarPart):
        (WebCore::RenderScrollbarPart::~RenderScrollbarPart):
        (WebCore::RenderScrollbarPart::layout):
        (WebCore::RenderScrollbarPart::layoutHorizontalPart):
        (WebCore::RenderScrollbarPart::layoutVerticalPart):
        (WebCore::calcScrollbarThicknessUsing):
        (WebCore::RenderScrollbarPart::computeScrollbarWidth):
        (WebCore::RenderScrollbarPart::computeScrollbarHeight):
        (WebCore::RenderScrollbarPart::calcPrefWidths):
        (WebCore::RenderScrollbarPart::setStyle):
        * rendering/RenderScrollbarPart.h: Added.
        (WebCore::RenderScrollbarPart::renderName):
        (WebCore::RenderScrollbarPart::requiresLayer):
        * rendering/RenderScrollbarTheme.cpp: Added.
        (WebCore::RenderScrollbarTheme::renderScrollbarTheme):
        (WebCore::RenderScrollbarTheme::buttonSizesAlongTrackAxis):
        (WebCore::RenderScrollbarTheme::hasButtons):
        (WebCore::RenderScrollbarTheme::hasThumb):
        (WebCore::RenderScrollbarTheme::minimumThumbLength):
        (WebCore::RenderScrollbarTheme::backButtonRect):
        (WebCore::RenderScrollbarTheme::forwardButtonRect):
        (WebCore::RenderScrollbarTheme::trackRect):
        (WebCore::RenderScrollbarTheme::paintScrollCorner):
        (WebCore::RenderScrollbarTheme::paintScrollbarBackground):
        (WebCore::RenderScrollbarTheme::paintTrackBackground):
        (WebCore::RenderScrollbarTheme::paintTrackPiece):
        (WebCore::RenderScrollbarTheme::paintButton):
        (WebCore::RenderScrollbarTheme::paintThumb):
        * rendering/RenderScrollbarTheme.h: Added.
        (WebCore::RenderScrollbarTheme::~RenderScrollbarTheme):
        (WebCore::RenderScrollbarTheme::scrollbarThickness):
        (WebCore::RenderScrollbarTheme::buttonsPlacement):
        (WebCore::RenderScrollbarTheme::supportsControlTints):
        (WebCore::RenderScrollbarTheme::shouldCenterOnThumb):
        (WebCore::RenderScrollbarTheme::initialAutoscrollTimerDelay):
        (WebCore::RenderScrollbarTheme::autoscrollTimerDelay):
        (WebCore::RenderScrollbarTheme::registerScrollbar):
        (WebCore::RenderScrollbarTheme::unregisterScrollbar):
        * rendering/style/RenderStyle.h:
        (WebCore::RenderStyle::):

LayoutTests:

2008-10-09  David Hyatt  <hyatt@apple.com>

        Land layout test for CSS scrollbars.

        Reviewed by Oliver Hunt

        * platform/mac/scrollbars: Added.
        * platform/mac/scrollbars/basic-scrollbar-expected.checksum: Added.
        * platform/mac/scrollbars/basic-scrollbar-expected.png: Added.
        * platform/mac/scrollbars/basic-scrollbar-expected.txt: Added.
        * scrollbars: Added.
        * scrollbars/basic-scrollbar.html: Added.

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

29 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/scrollbars/basic-scrollbar-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/scrollbars/basic-scrollbar-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/scrollbars/basic-scrollbar-expected.txt [new file with mode: 0644]
LayoutTests/scrollbars/basic-scrollbar.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/css/CSSSelector.cpp
WebCore/css/CSSSelector.h
WebCore/css/CSSStyleSelector.cpp
WebCore/platform/ScrollTypes.h
WebCore/platform/Scrollbar.h
WebCore/platform/ScrollbarThemeComposite.cpp
WebCore/platform/ScrollbarThemeComposite.h
WebCore/platform/win/ScrollbarThemeSafari.cpp
WebCore/platform/win/ScrollbarThemeSafari.h
WebCore/platform/win/ScrollbarThemeWin.cpp
WebCore/platform/win/ScrollbarThemeWin.h
WebCore/rendering/RenderLayer.cpp
WebCore/rendering/RenderScrollbar.cpp [new file with mode: 0644]
WebCore/rendering/RenderScrollbar.h [new file with mode: 0644]
WebCore/rendering/RenderScrollbarPart.cpp [new file with mode: 0644]
WebCore/rendering/RenderScrollbarPart.h [new file with mode: 0644]
WebCore/rendering/RenderScrollbarTheme.cpp [new file with mode: 0644]
WebCore/rendering/RenderScrollbarTheme.h [new file with mode: 0644]
WebCore/rendering/style/RenderStyle.h

index 16ce99a..c0a47ff 100644 (file)
@@ -1,3 +1,16 @@
+2008-10-09  David Hyatt  <hyatt@apple.com>
+
+        Land layout test for CSS scrollbars.
+
+        Reviewed by Oliver Hunt
+
+        * platform/mac/scrollbars: Added.
+        * platform/mac/scrollbars/basic-scrollbar-expected.checksum: Added.
+        * platform/mac/scrollbars/basic-scrollbar-expected.png: Added.
+        * platform/mac/scrollbars/basic-scrollbar-expected.txt: Added.
+        * scrollbars: Added.
+        * scrollbars/basic-scrollbar.html: Added.
+
 2008-10-09  Eric Seidel  <eric@webkit.org>
 
         Reviewed by Oliver Hunt.
diff --git a/LayoutTests/platform/mac/scrollbars/basic-scrollbar-expected.checksum b/LayoutTests/platform/mac/scrollbars/basic-scrollbar-expected.checksum
new file mode 100644 (file)
index 0000000..1dfd1a4
--- /dev/null
@@ -0,0 +1 @@
+f69167910932d149dce9a1d9475fa232
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/scrollbars/basic-scrollbar-expected.png b/LayoutTests/platform/mac/scrollbars/basic-scrollbar-expected.png
new file mode 100644 (file)
index 0000000..acc8508
Binary files /dev/null and b/LayoutTests/platform/mac/scrollbars/basic-scrollbar-expected.png differ
diff --git a/LayoutTests/platform/mac/scrollbars/basic-scrollbar-expected.txt b/LayoutTests/platform/mac/scrollbars/basic-scrollbar-expected.txt
new file mode 100644 (file)
index 0000000..bd3c3f8
--- /dev/null
@@ -0,0 +1,154 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+layer at (8,8) size 200x200 clip at (8,8) size 183x200 scrollHeight 882
+  RenderBlock {DIV} at (0,0) size 200x200
+    RenderText {#text} at (0,0) size 35x18
+      text run at (0,0) width 35: "Hello"
+    RenderBR {BR} at (35,14) size 0x0
+    RenderText {#text} at (0,18) size 35x18
+      text run at (0,18) width 35: "Hello"
+    RenderBR {BR} at (35,32) size 0x0
+    RenderText {#text} at (0,36) size 35x18
+      text run at (0,36) width 35: "Hello"
+    RenderBR {BR} at (35,50) size 0x0
+    RenderText {#text} at (0,54) size 35x18
+      text run at (0,54) width 35: "Hello"
+    RenderBR {BR} at (35,68) size 0x0
+    RenderText {#text} at (0,72) size 35x18
+      text run at (0,72) width 35: "Hello"
+    RenderBR {BR} at (35,86) size 0x0
+    RenderText {#text} at (0,90) size 35x18
+      text run at (0,90) width 35: "Hello"
+    RenderBR {BR} at (35,104) size 0x0
+    RenderText {#text} at (0,108) size 35x18
+      text run at (0,108) width 35: "Hello"
+    RenderBR {BR} at (35,122) size 0x0
+    RenderText {#text} at (0,126) size 35x18
+      text run at (0,126) width 35: "Hello"
+    RenderBR {BR} at (35,140) size 0x0
+    RenderText {#text} at (0,144) size 35x18
+      text run at (0,144) width 35: "Hello"
+    RenderBR {BR} at (35,158) size 0x0
+    RenderText {#text} at (0,162) size 35x18
+      text run at (0,162) width 35: "Hello"
+    RenderBR {BR} at (35,176) size 0x0
+    RenderText {#text} at (0,180) size 35x18
+      text run at (0,180) width 35: "Hello"
+    RenderBR {BR} at (35,194) size 0x0
+    RenderText {#text} at (0,198) size 35x18
+      text run at (0,198) width 35: "Hello"
+    RenderBR {BR} at (35,212) size 0x0
+    RenderText {#text} at (0,216) size 35x18
+      text run at (0,216) width 35: "Hello"
+    RenderBR {BR} at (35,230) size 0x0
+    RenderText {#text} at (0,234) size 35x18
+      text run at (0,234) width 35: "Hello"
+    RenderBR {BR} at (35,248) size 0x0
+    RenderText {#text} at (0,252) size 35x18
+      text run at (0,252) width 35: "Hello"
+    RenderBR {BR} at (35,266) size 0x0
+    RenderText {#text} at (0,270) size 35x18
+      text run at (0,270) width 35: "Hello"
+    RenderBR {BR} at (35,284) size 0x0
+    RenderText {#text} at (0,288) size 35x18
+      text run at (0,288) width 35: "Hello"
+    RenderBR {BR} at (35,302) size 0x0
+    RenderText {#text} at (0,306) size 35x18
+      text run at (0,306) width 35: "Hello"
+    RenderBR {BR} at (35,320) size 0x0
+    RenderText {#text} at (0,324) size 35x18
+      text run at (0,324) width 35: "Hello"
+    RenderBR {BR} at (35,338) size 0x0
+    RenderText {#text} at (0,342) size 35x18
+      text run at (0,342) width 35: "Hello"
+    RenderBR {BR} at (35,356) size 0x0
+    RenderText {#text} at (0,360) size 35x18
+      text run at (0,360) width 35: "Hello"
+    RenderBR {BR} at (35,374) size 0x0
+    RenderText {#text} at (0,378) size 35x18
+      text run at (0,378) width 35: "Hello"
+    RenderBR {BR} at (35,392) size 0x0
+    RenderText {#text} at (0,396) size 35x18
+      text run at (0,396) width 35: "Hello"
+    RenderBR {BR} at (35,410) size 0x0
+    RenderText {#text} at (0,414) size 35x18
+      text run at (0,414) width 35: "Hello"
+    RenderBR {BR} at (35,428) size 0x0
+    RenderText {#text} at (0,432) size 35x18
+      text run at (0,432) width 35: "Hello"
+    RenderBR {BR} at (35,446) size 0x0
+    RenderText {#text} at (0,450) size 35x18
+      text run at (0,450) width 35: "Hello"
+    RenderBR {BR} at (35,464) size 0x0
+    RenderText {#text} at (0,468) size 35x18
+      text run at (0,468) width 35: "Hello"
+    RenderBR {BR} at (35,482) size 0x0
+    RenderText {#text} at (0,486) size 35x18
+      text run at (0,486) width 35: "Hello"
+    RenderBR {BR} at (35,500) size 0x0
+    RenderText {#text} at (0,504) size 35x18
+      text run at (0,504) width 35: "Hello"
+    RenderBR {BR} at (35,518) size 0x0
+    RenderText {#text} at (0,522) size 35x18
+      text run at (0,522) width 35: "Hello"
+    RenderBR {BR} at (35,536) size 0x0
+    RenderText {#text} at (0,540) size 35x18
+      text run at (0,540) width 35: "Hello"
+    RenderBR {BR} at (35,554) size 0x0
+    RenderText {#text} at (0,558) size 35x18
+      text run at (0,558) width 35: "Hello"
+    RenderBR {BR} at (35,572) size 0x0
+    RenderText {#text} at (0,576) size 35x18
+      text run at (0,576) width 35: "Hello"
+    RenderBR {BR} at (35,590) size 0x0
+    RenderText {#text} at (0,594) size 35x18
+      text run at (0,594) width 35: "Hello"
+    RenderBR {BR} at (35,608) size 0x0
+    RenderText {#text} at (0,612) size 35x18
+      text run at (0,612) width 35: "Hello"
+    RenderBR {BR} at (35,626) size 0x0
+    RenderText {#text} at (0,630) size 35x18
+      text run at (0,630) width 35: "Hello"
+    RenderBR {BR} at (35,644) size 0x0
+    RenderText {#text} at (0,648) size 35x18
+      text run at (0,648) width 35: "Hello"
+    RenderBR {BR} at (35,662) size 0x0
+    RenderText {#text} at (0,666) size 35x18
+      text run at (0,666) width 35: "Hello"
+    RenderBR {BR} at (35,680) size 0x0
+    RenderText {#text} at (0,684) size 35x18
+      text run at (0,684) width 35: "Hello"
+    RenderBR {BR} at (35,698) size 0x0
+    RenderText {#text} at (0,702) size 35x18
+      text run at (0,702) width 35: "Hello"
+    RenderBR {BR} at (35,716) size 0x0
+    RenderText {#text} at (0,720) size 35x18
+      text run at (0,720) width 35: "Hello"
+    RenderBR {BR} at (35,734) size 0x0
+    RenderText {#text} at (0,738) size 35x18
+      text run at (0,738) width 35: "Hello"
+    RenderBR {BR} at (35,752) size 0x0
+    RenderText {#text} at (0,756) size 35x18
+      text run at (0,756) width 35: "Hello"
+    RenderBR {BR} at (35,770) size 0x0
+    RenderText {#text} at (0,774) size 35x18
+      text run at (0,774) width 35: "Hello"
+    RenderBR {BR} at (35,788) size 0x0
+    RenderText {#text} at (0,792) size 35x18
+      text run at (0,792) width 35: "Hello"
+    RenderBR {BR} at (35,806) size 0x0
+    RenderText {#text} at (0,810) size 35x18
+      text run at (0,810) width 35: "Hello"
+    RenderBR {BR} at (35,824) size 0x0
+    RenderText {#text} at (0,828) size 35x18
+      text run at (0,828) width 35: "Hello"
+    RenderBR {BR} at (35,842) size 0x0
+    RenderText {#text} at (0,846) size 35x18
+      text run at (0,846) width 35: "Hello"
+    RenderBR {BR} at (35,860) size 0x0
+    RenderText {#text} at (0,864) size 35x18
+      text run at (0,864) width 35: "Hello"
+    RenderBR {BR} at (35,878) size 0x0
diff --git a/LayoutTests/scrollbars/basic-scrollbar.html b/LayoutTests/scrollbars/basic-scrollbar.html
new file mode 100644 (file)
index 0000000..0eda425
--- /dev/null
@@ -0,0 +1,36 @@
+<head>
+<style>
+div::-webkit-scrollbar {
+  width:17px;
+  height:17px;
+  background-color:grey;
+}
+
+div::-webkit-scrollbar-button {
+  width: 17px;
+  height: 17px;
+  background-color:lightblue;
+  border:2px solid black;
+}
+
+div::-webkit-scrollbar-thumb {
+  background-color: navy;
+  border:2px solid #cccccc;
+}
+</style>
+</head>
+<body>
+<div style="width:200px; height:200px; overflow:auto">
+Hello<br>
+Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>
+Hello<br>Hello<br>Hello<br>Hello<br>
+Hello<br>Hello<br>Hello<br>Hello<br>
+Hello<br>Hello<br>Hello<br>
+Hello<br>Hello<br>Hello<br>
+Hello<br>Hello<br>Hello<br>Hello<br>
+Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>
+Hello<br>Hello<br>Hello<br>Hello<br>
+Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>
+Hello<br>Hello<br>Hello<br>Hello<br>
+Hello<br>Hello<br>Hello<br>
+</div>
index 101eb90..4b094a0 100644 (file)
@@ -1,3 +1,96 @@
+2008-10-09  David Hyatt  <hyatt@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=21446
+
+        This patch gets CSS scrollbars up and limping.  There's no way to distinguish between states or between
+        orientation and back vs. forward on the buttons, but it's a start.
+
+        Reviewed by Oliver Hunt
+
+        Added scrollbars/basic-scrollbar.html
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::extractPseudoType):
+        * css/CSSSelector.h:
+        (WebCore::CSSSelector::):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
+        * platform/ScrollTypes.h:
+        (WebCore::):
+        * platform/Scrollbar.h:
+        (WebCore::Scrollbar::styleChanged):
+        * platform/ScrollbarThemeComposite.cpp:
+        (WebCore::ScrollbarThemeComposite::paint):
+        (WebCore::ScrollbarThemeComposite::splitTrack):
+        * platform/ScrollbarThemeComposite.h:
+        (WebCore::ScrollbarThemeComposite::paintScrollbarBackground):
+        (WebCore::ScrollbarThemeComposite::paintTrackBackground):
+        (WebCore::ScrollbarThemeComposite::paintTrackPiece):
+        * platform/win/ScrollbarThemeSafari.cpp:
+        (WebCore::ScrollbarThemeSafari::paintTrackBackground):
+        * platform/win/ScrollbarThemeSafari.h:
+        * platform/win/ScrollbarThemeWin.cpp:
+        (WebCore::ScrollbarThemeWin::paintTrack):
+        * platform/win/ScrollbarThemeWin.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::createScrollbar):
+        (WebCore::RenderLayer::styleChanged):
+        * rendering/RenderScrollbar.cpp: Added.
+        (WebCore::RenderScrollbar::createCustomScrollbar):
+        (WebCore::RenderScrollbar::RenderScrollbar):
+        (WebCore::RenderScrollbar::~RenderScrollbar):
+        (WebCore::RenderScrollbar::getScrollbarPseudoStyle):
+        (WebCore::RenderScrollbar::updateScrollbarParts):
+        (WebCore::RenderScrollbar::updateScrollbarPart):
+        (WebCore::RenderScrollbar::paintPart):
+        (WebCore::RenderScrollbar::buttonRect):
+        (WebCore::RenderScrollbar::minimumThumbLength):
+        * rendering/RenderScrollbar.h: Added.
+        (WebCore::RenderScrollbar::styleChanged):
+        (WebCore::RenderScrollbar::owningRenderer):
+        * rendering/RenderScrollbarPart.cpp: Added.
+        (WebCore::RenderScrollbarPart::RenderScrollbarPart):
+        (WebCore::RenderScrollbarPart::~RenderScrollbarPart):
+        (WebCore::RenderScrollbarPart::layout):
+        (WebCore::RenderScrollbarPart::layoutHorizontalPart):
+        (WebCore::RenderScrollbarPart::layoutVerticalPart):
+        (WebCore::calcScrollbarThicknessUsing):
+        (WebCore::RenderScrollbarPart::computeScrollbarWidth):
+        (WebCore::RenderScrollbarPart::computeScrollbarHeight):
+        (WebCore::RenderScrollbarPart::calcPrefWidths):
+        (WebCore::RenderScrollbarPart::setStyle):
+        * rendering/RenderScrollbarPart.h: Added.
+        (WebCore::RenderScrollbarPart::renderName):
+        (WebCore::RenderScrollbarPart::requiresLayer):
+        * rendering/RenderScrollbarTheme.cpp: Added.
+        (WebCore::RenderScrollbarTheme::renderScrollbarTheme):
+        (WebCore::RenderScrollbarTheme::buttonSizesAlongTrackAxis):
+        (WebCore::RenderScrollbarTheme::hasButtons):
+        (WebCore::RenderScrollbarTheme::hasThumb):
+        (WebCore::RenderScrollbarTheme::minimumThumbLength):
+        (WebCore::RenderScrollbarTheme::backButtonRect):
+        (WebCore::RenderScrollbarTheme::forwardButtonRect):
+        (WebCore::RenderScrollbarTheme::trackRect):
+        (WebCore::RenderScrollbarTheme::paintScrollCorner):
+        (WebCore::RenderScrollbarTheme::paintScrollbarBackground):
+        (WebCore::RenderScrollbarTheme::paintTrackBackground):
+        (WebCore::RenderScrollbarTheme::paintTrackPiece):
+        (WebCore::RenderScrollbarTheme::paintButton):
+        (WebCore::RenderScrollbarTheme::paintThumb):
+        * rendering/RenderScrollbarTheme.h: Added.
+        (WebCore::RenderScrollbarTheme::~RenderScrollbarTheme):
+        (WebCore::RenderScrollbarTheme::scrollbarThickness):
+        (WebCore::RenderScrollbarTheme::buttonsPlacement):
+        (WebCore::RenderScrollbarTheme::supportsControlTints):
+        (WebCore::RenderScrollbarTheme::shouldCenterOnThumb):
+        (WebCore::RenderScrollbarTheme::initialAutoscrollTimerDelay):
+        (WebCore::RenderScrollbarTheme::autoscrollTimerDelay):
+        (WebCore::RenderScrollbarTheme::registerScrollbar):
+        (WebCore::RenderScrollbarTheme::unregisterScrollbar):
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::):
+
 2008-10-09  Eric Seidel  <eric@webkit.org>
 
         Reviewed by Oliver Hunt.
index 121292e..a7662c9 100644 (file)
@@ -1542,6 +1542,12 @@ webcore_sources += \
        WebCore/rendering/RenderReplica.h \
        WebCore/rendering/RenderSlider.cpp \
        WebCore/rendering/RenderSlider.h \
+       WebCore/rendering/RenderScrollbar.cpp \
+       WebCore/rendering/RenderScrollbar.h \
+       WebCore/rendering/RenderScrollbarPart.cpp \
+       WebCore/rendering/RenderScrollbarPart.h \
+       WebCore/rendering/RenderScrollbarTheme.cpp \
+       WebCore/rendering/RenderScrollbarTheme.h \
        WebCore/rendering/RenderTable.cpp \
        WebCore/rendering/RenderTable.h \
        WebCore/rendering/RenderTableCell.cpp \
index 76523b1..fcc23f7 100644 (file)
@@ -904,6 +904,9 @@ SOURCES += \
     rendering/RenderPartObject.cpp \
     rendering/RenderReplaced.cpp \
     rendering/RenderReplica.cpp \
+    rendering/RenderScrollbar.cpp \
+    rendering/RenderScrollbarPart.cpp \
+    rendering/RenderScrollbarTheme.cpp \
     rendering/RenderSlider.cpp \
     rendering/RenderTableCell.cpp \
     rendering/RenderTableCol.cpp \
index 8a4226e..b81e0c5 100644 (file)
                                RelativePath="..\rendering\RenderReplica.h"\r
                                >\r
                        </File>\r
+                        <File\r
+                               RelativePath="..\rendering\RenderScrollbar.cpp"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release_PGO|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               WholeProgramOptimization="true"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\rendering\RenderScrollbar.h"\r
+                               >\r
+                       </File>\r
+                        <File\r
+                               RelativePath="..\rendering\RenderScrollbarPart.cpp"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release_PGO|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               WholeProgramOptimization="true"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\rendering\RenderScrollbarPart.h"\r
+                               >\r
+                       </File>\r
+                        <File\r
+                               RelativePath="..\rendering\RenderScrollbarTheme.cpp"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release_PGO|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               WholeProgramOptimization="true"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\rendering\RenderScrollbarTheme.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\rendering\RenderSlider.cpp"\r
                                >\r
index 5d310a8..3686cf6 100644 (file)
                BC3B7B210E91AAF400D54065 /* JSEventTargetNodeCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC3B7B200E91AAF400D54065 /* JSEventTargetNodeCustom.cpp */; };
                BC3BC29C0E91AB0F00835588 /* HostWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3BC29B0E91AB0F00835588 /* HostWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC3BE12B0E98092F00835588 /* PopupMenuStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3BE12A0E98092F00835588 /* PopupMenuStyle.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               BC3BE9930E9C1C7C00835588 /* RenderScrollbar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC3BE9900E9C1C7C00835588 /* RenderScrollbar.cpp */; };
+               BC3BE9940E9C1C7C00835588 /* RenderScrollbar.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3BE9910E9C1C7C00835588 /* RenderScrollbar.h */; };
+               BC3BE9950E9C1C7C00835588 /* RenderScrollbarPart.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3BE9920E9C1C7C00835588 /* RenderScrollbarPart.h */; };
+               BC3BE9990E9C1E5D00835588 /* RenderScrollbarTheme.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3BE9980E9C1E5D00835588 /* RenderScrollbarTheme.h */; };
+               BC3BE9A50E9C239600835588 /* RenderScrollbarTheme.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC3BE9A40E9C239600835588 /* RenderScrollbarTheme.cpp */; };
+               BC3BE9AB0E9C242000835588 /* RenderScrollbarPart.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC3BE9AA0E9C242000835588 /* RenderScrollbarPart.cpp */; };
                BC3C39B60C0D3D8D005F4D7A /* JSMediaList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */; };
                BC3C39B70C0D3D8D005F4D7A /* JSMediaList.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */; };
                BC4368E80C226E32005EFB5F /* Rect.h in Headers */ = {isa = PBXBuildFile; fileRef = BC4368E70C226E32005EFB5F /* Rect.h */; };
                BC3B7B200E91AAF400D54065 /* JSEventTargetNodeCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEventTargetNodeCustom.cpp; sourceTree = "<group>"; };
                BC3BC29B0E91AB0F00835588 /* HostWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HostWindow.h; sourceTree = "<group>"; };
                BC3BE12A0E98092F00835588 /* PopupMenuStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopupMenuStyle.h; sourceTree = "<group>"; };
+               BC3BE9900E9C1C7C00835588 /* RenderScrollbar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderScrollbar.cpp; sourceTree = "<group>"; };
+               BC3BE9910E9C1C7C00835588 /* RenderScrollbar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderScrollbar.h; sourceTree = "<group>"; };
+               BC3BE9920E9C1C7C00835588 /* RenderScrollbarPart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderScrollbarPart.h; sourceTree = "<group>"; };
+               BC3BE9980E9C1E5D00835588 /* RenderScrollbarTheme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderScrollbarTheme.h; sourceTree = "<group>"; };
+               BC3BE9A40E9C239600835588 /* RenderScrollbarTheme.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderScrollbarTheme.cpp; sourceTree = "<group>"; };
+               BC3BE9AA0E9C242000835588 /* RenderScrollbarPart.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderScrollbarPart.cpp; sourceTree = "<group>"; };
                BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaList.cpp; sourceTree = "<group>"; };
                BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSMediaList.h; sourceTree = "<group>"; };
                BC4368E70C226E32005EFB5F /* Rect.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Rect.h; sourceTree = "<group>"; };
                                ABDDFE730A5C6E6F00A3E11D /* RenderMenuList.cpp */,
                                ABDDFE740A5C6E7000A3E11D /* RenderMenuList.h */,
                                BCEA4840097D93020094C9E4 /* RenderObject.cpp */,
+                               BC3BE9AA0E9C242000835588 /* RenderScrollbarPart.cpp */,
+                               BC3BE9A40E9C239600835588 /* RenderScrollbarTheme.cpp */,
+                               BC3BE9980E9C1E5D00835588 /* RenderScrollbarTheme.h */,
                                BCEA4841097D93020094C9E4 /* RenderObject.h */,
                                A871DEC80A1530C700B12A68 /* RenderPart.cpp */,
                                A871DECF0A1530C700B12A68 /* RenderPart.h */,
                                A871DFDF0A15376B00B12A68 /* RenderReplaced.h */,
                                BCA846D40DC67A350026C309 /* RenderReplica.cpp */,
                                BCA846D50DC67A350026C309 /* RenderReplica.h */,
+                               BC3BE9900E9C1C7C00835588 /* RenderScrollbar.cpp */,
+                               BC3BE9910E9C1C7C00835588 /* RenderScrollbar.h */,
+                               BC3BE9920E9C1C7C00835588 /* RenderScrollbarPart.h */,
                                AB247A6A0AFD6383003FA5FD /* RenderSlider.cpp */,
                                AB247A6B0AFD6383003FA5FD /* RenderSlider.h */,
                                A7352C170B1BB89D00A986D0 /* RenderSVGBlock.cpp */,
                                1C81BA0C0E97348300266E07 /* JavaScriptDebugListener.h in Headers */,
                                1C81BA0E0E97348300266E07 /* JavaScriptDebugServer.h in Headers */,
                                BC3BE12B0E98092F00835588 /* PopupMenuStyle.h in Headers */,
+                               BC3BE9940E9C1C7C00835588 /* RenderScrollbar.h in Headers */,
+                               BC3BE9950E9C1C7C00835588 /* RenderScrollbarPart.h in Headers */,
+                               BC3BE9990E9C1E5D00835588 /* RenderScrollbarTheme.h in Headers */,
                                1CF6BDFA0E9BB26A0025E1CD /* ObjCEventListener.h in Headers */,
                                1CF6BE150E9BB4670025E1CD /* ObjCNodeFilterCondition.h in Headers */,
                                A80D67080E9E9DEB00E420F0 /* GraphicsContextPlatformPrivateCG.h in Headers */,
                                1C81BA020E9733CB00266E07 /* JavaScriptProfile.cpp in Sources */,
                                1C81BA090E97348300266E07 /* JavaScriptCallFrame.cpp in Sources */,
                                1C81BA0D0E97348300266E07 /* JavaScriptDebugServer.cpp in Sources */,
+                               BC3BE9930E9C1C7C00835588 /* RenderScrollbar.cpp in Sources */,
+                               BC3BE9A50E9C239600835588 /* RenderScrollbarTheme.cpp in Sources */,
+                               BC3BE9AB0E9C242000835588 /* RenderScrollbarPart.cpp in Sources */,
                                1CF6BDFB0E9BB26A0025E1CD /* ObjCEventListener.mm in Sources */,
                                1CF6BE140E9BB4670025E1CD /* ObjCNodeFilterCondition.mm in Sources */,
                        );
index 1cd90cd..5b8b4c2 100644 (file)
@@ -114,6 +114,7 @@ void CSSSelector::extractPseudoType() const
     static AtomicString scrollbarHorizontal("-webkit-scrollbar-horizontal");
     static AtomicString scrollbarThumb("-webkit-scrollbar-thumb");
     static AtomicString scrollbarTrack("-webkit-scrollbar-track");
+    static AtomicString scrollbarTrackPiece("-webkit-scrollbar-track-piece");
     static AtomicString scrollbarVertical("-webkit-scrollbar-vertical");
     static AtomicString searchCancelButton("-webkit-search-cancel-button");
     static AtomicString searchDecoration("-webkit-search-decoration");
@@ -253,6 +254,9 @@ void CSSSelector::extractPseudoType() const
     } else if (m_value == scrollbarTrack) {
         element = true;
         m_pseudoType = PseudoScrollbarTrack;
+    } else if (m_value == scrollbarTrackPiece) {
+        element = true;
+        m_pseudoType = PseudoScrollbarTrackPiece;
     } else if (m_value == scrollbarVertical)
         m_pseudoType = PseudoScrollbarVertical;
     else if (m_value == searchCancelButton) {
index 97e0c08..b4a27a4 100644 (file)
@@ -159,6 +159,7 @@ namespace WebCore {
             PseudoScrollbarHorizontal,
             PseudoScrollbarThumb,
             PseudoScrollbarTrack,
+            PseudoScrollbarTrackPiece,
             PseudoScrollbarVertical,
             PseudoSelection,
             PseudoFileUploadButton,
index b721d1c..87a8ecc 100644 (file)
@@ -2339,6 +2339,24 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
             case CSSSelector::PseudoMediaControlsFullscreenButton:
                 dynamicPseudo = RenderStyle::MEDIA_CONTROLS_FULLSCREEN_BUTTON;
                 return true;
+            case CSSSelector::PseudoScrollbar:
+                dynamicPseudo = RenderStyle::SCROLLBAR;
+                return true;
+            case CSSSelector::PseudoScrollbarButton:
+                dynamicPseudo = RenderStyle::SCROLLBAR_BUTTON;
+                return true;
+            case CSSSelector::PseudoScrollbarCorner:
+                dynamicPseudo = RenderStyle::SCROLLBAR_CORNER;
+                return true;
+            case CSSSelector::PseudoScrollbarThumb:
+                dynamicPseudo = RenderStyle::SCROLLBAR_THUMB;
+                return true;
+            case CSSSelector::PseudoScrollbarTrack:
+                dynamicPseudo = RenderStyle::SCROLLBAR_TRACK;
+                return true;
+            case CSSSelector::PseudoScrollbarTrackPiece:
+                dynamicPseudo = RenderStyle::SCROLLBAR_TRACK_PIECE;
+                return true;
             case CSSSelector::PseudoUnknown:
             case CSSSelector::PseudoNotParsed:
             default:
index 27feb0e..eba9055 100644 (file)
@@ -65,6 +65,8 @@ namespace WebCore {
         ForwardTrackPart = 1 << 4,
         BackButtonEndPart = 1 << 5,
         ForwardButtonEndPart = 1 << 6,
+        ScrollbarBGPart = 1 << 7,
+        TrackBGPart = 1 << 8,
         AllParts = 0xffffffff,
     };
 
index 29ea902..802bcd7 100644 (file)
@@ -120,6 +120,8 @@ public:
     bool suppressInvalidation() const { return m_suppressInvalidation; }
     void setSuppressInvalidation(bool s) { m_suppressInvalidation = s; }
 
+    virtual void styleChanged() { }
+
 protected:
     virtual void updateThumbPosition();
     virtual void updateThumbProportion();
index 8da587d..e09f410 100644 (file)
@@ -84,15 +84,8 @@ bool ScrollbarThemeComposite::paint(Scrollbar* scrollbar, GraphicsContext* graph
     if (thumbPresent) {
         IntRect track = trackRect(scrollbar);
         splitTrack(scrollbar, track, startTrackRect, thumbRect, endTrackRect);
-        if (damageRect.intersects(thumbRect)) {
+        if (damageRect.intersects(thumbRect))
             scrollMask |= ThumbPart;
-            if (trackIsSinglePiece()) {
-                // The track is a single strip that paints under the thumb.
-                // Add both components of the track to the mask.
-                scrollMask |= BackTrackPart;
-                scrollMask |= ForwardTrackPart;
-            }
-        }
         if (damageRect.intersects(startTrackRect))
             scrollMask |= BackTrackPart;
         if (damageRect.intersects(endTrackRect))
@@ -131,16 +124,20 @@ bool ScrollbarThemeComposite::paint(Scrollbar* scrollbar, GraphicsContext* graph
     }
 #endif
 
-    // Paint the track.
+    // Paint the scrollbar background (only used by custom CSS scrollbars).
+    paintScrollbarBackground(graphicsContext, scrollbar);
+
+    // Paint the track background.
+    if ((scrollMask & ForwardTrackPart) || (scrollMask & BackTrackPart) || (scrollMask && ThumbPart))
+        paintTrackBackground(graphicsContext, scrollbar, trackPaintRect);
+    
+    // Paint the track pieces above and below the thumb.
     if ((scrollMask & ForwardTrackPart) || (scrollMask & BackTrackPart)) {
-        if (!thumbPresent || trackIsSinglePiece())
-            paintTrack(graphicsContext, scrollbar, trackPaintRect, ForwardTrackPart | BackTrackPart);
-        else {
-            if (scrollMask & BackTrackPart)
-                paintTrack(graphicsContext, scrollbar, startTrackRect, BackTrackPart);
-            if (scrollMask & ForwardTrackPart)
-                paintTrack(graphicsContext, scrollbar, endTrackRect, ForwardTrackPart);
-        }
+        
+        if (scrollMask & BackTrackPart)
+            paintTrackPiece(graphicsContext, scrollbar, startTrackRect, BackTrackPart);
+        if (scrollMask & ForwardTrackPart)
+            paintTrackPiece(graphicsContext, scrollbar, endTrackRect, ForwardTrackPart);
     }
 
     // Paint the back and forward buttons.
@@ -232,7 +229,7 @@ void ScrollbarThemeComposite::splitTrack(Scrollbar* scrollbar, const IntRect& tr
 {
     // This function won't even get called unless we're big enough to have some combination of these three rects where at least
     // one of them is non-empty.
-    int thickness = scrollbarThickness();
+    int thickness = scrollbar->orientation() == HorizontalScrollbar ? scrollbar->height() : scrollbar->width();
     int thumbPos = thumbPosition(scrollbar);
     if (scrollbar->orientation() == HorizontalScrollbar) {
         thumbRect = IntRect(trackRect.x() + thumbPos, trackRect.y() + (trackRect.height() - thickness) / 2, thumbLength(scrollbar), thickness);
index 6336c7c..90a8e30 100644 (file)
@@ -54,12 +54,12 @@ protected:
     virtual IntRect trackRect(Scrollbar*, bool painting = false) = 0;
 
     virtual void splitTrack(Scrollbar*, const IntRect& track, IntRect& startTrack, IntRect& thumb, IntRect& endTrack);
-    
-    virtual bool trackIsSinglePiece() { return true; }
 
     virtual int minimumThumbLength(Scrollbar*);
 
-    virtual void paintTrack(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarControlPartMask) {}
+    virtual void paintScrollbarBackground(GraphicsContext*, Scrollbar*) {}
+    virtual void paintTrackBackground(GraphicsContext*, Scrollbar*, const IntRect&) {}
+    virtual void paintTrackPiece(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart) {}
     virtual void paintButton(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart) {}
     virtual void paintThumb(GraphicsContext*, Scrollbar*, const IntRect&) {}
 };
index 18ed654..06a6533 100644 (file)
@@ -203,7 +203,7 @@ bool ScrollbarThemeSafari::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEv
     return evt.shiftKey() && evt.button() == LeftButton;
 }
 
-void ScrollbarThemeSafari::paintTrack(GraphicsContext* graphicsContext, Scrollbar* scrollbar, const IntRect& trackRect, ScrollbarControlPartMask)
+void ScrollbarThemeSafari::paintTrackBackground(GraphicsContext* graphicsContext, Scrollbar* scrollbar, const IntRect& trackRect)
 {
     if (!SafariThemeLibrary())
         return;
index 1f49db3..f039379 100644 (file)
@@ -52,7 +52,7 @@ protected:
     
     virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&);
 
-    virtual void paintTrack(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarControlPartMask);
+    virtual void paintTrackBackground(GraphicsContext*, Scrollbar*, const IntRect&);
     virtual void paintButton(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart);
     virtual void paintThumb(GraphicsContext*, Scrollbar*, const IntRect&);
 };
index 056c05a..c4ba915 100644 (file)
@@ -194,11 +194,11 @@ IntRect ScrollbarThemeWin::trackRect(Scrollbar* scrollbar, bool)
     return IntRect(scrollbar->x(), scrollbar->y() + thickness, thickness, scrollbar->height() - 2 * thickness);
 }
 
-void ScrollbarThemeWin::paintTrack(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect, ScrollbarControlPartMask mask)
+void ScrollbarThemeWin::paintTrack(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart partType)
 {
     checkAndInitScrollbarTheme();
 
-    bool start = mask & BackTrackPart;
+    bool start = partType == BackTrackPart;
     int part;
     if (scrollbar->orientation() == HorizontalScrollbar)
         part = start ? SP_TRACKSTARTHOR : SP_TRACKENDHOR;
index 7f21e4f..bea07cd 100644 (file)
@@ -48,12 +48,10 @@ protected:
     virtual IntRect backButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
     virtual IntRect forwardButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
     virtual IntRect trackRect(Scrollbar*, bool painting = false);
-   
-    virtual bool trackIsSinglePiece() { return false; }
-    
+
     virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&);
 
-    virtual void paintTrack(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarControlPartMask);
+    virtual void paintTrackPiece(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart);
     virtual void paintButton(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart);
     virtual void paintThumb(GraphicsContext*, Scrollbar*, const IntRect&);
 };
index efc10e2..177d03c 100644 (file)
@@ -65,6 +65,7 @@
 #include "RenderInline.h"
 #include "RenderMarquee.h"
 #include "RenderReplica.h"
+#include "RenderScrollbar.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
 #include "ScaleTransformOperation.h"
@@ -1110,7 +1111,12 @@ void RenderLayer::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& r
 
 PassRefPtr<Scrollbar> RenderLayer::createScrollbar(ScrollbarOrientation orientation)
 {
-    RefPtr<Scrollbar> widget = Scrollbar::createNativeScrollbar(this, orientation, RegularScrollbar);
+    RefPtr<Scrollbar> widget;
+    RenderStyle* style = renderer()->getPseudoStyle(RenderStyle::SCROLLBAR);
+    if (style)
+        widget = RenderScrollbar::createCustomScrollbar(this, orientation, style, renderer());
+    else
+        widget = Scrollbar::createNativeScrollbar(this, orientation, RegularScrollbar);
     m_object->document()->view()->addChild(widget.get());        
     return widget.release();
 }
@@ -2380,6 +2386,12 @@ void RenderLayer::styleChanged(RenderStyle* oldStyle)
             createReflection();
         updateReflectionStyle();
     }
+    
+    // FIXME: Need to detect a swap from custom to native scrollbars (and vice versa).
+    if (m_hBar)
+        m_hBar->styleChanged();
+    if (m_vBar)
+        m_vBar->styleChanged();
 }
 
 RenderLayer* RenderLayer::reflectionLayer() const
diff --git a/WebCore/rendering/RenderScrollbar.cpp b/WebCore/rendering/RenderScrollbar.cpp
new file mode 100644 (file)
index 0000000..86d0649
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2008 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 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 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 "RenderScrollbar.h"
+#include "RenderScrollbarPart.h"
+#include "RenderScrollbarTheme.h"
+
+namespace WebCore {
+
+PassRefPtr<Scrollbar> RenderScrollbar::createCustomScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, RenderStyle* style, RenderObject* renderer)
+{
+    return adoptRef(new RenderScrollbar(client, orientation, style, renderer));
+}
+
+RenderScrollbar::RenderScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, RenderStyle* style, RenderObject* renderer)
+    : Scrollbar(client, orientation, RegularScrollbar, RenderScrollbarTheme::renderScrollbarTheme())
+    , m_owner(renderer)
+{
+    updateScrollbarParts(style);
+}
+
+RenderScrollbar::~RenderScrollbar()
+{
+    // Destroy all of the scrollbar's RenderObjects.
+    updateScrollbarParts(0, true);
+}
+
+static ScrollbarPart gStyleResolvePart;
+static RenderScrollbar* gStyleResolveScrollbar;
+
+RenderStyle* RenderScrollbar::getScrollbarPseudoStyle(ScrollbarPart partType, RenderStyle::PseudoId pseudoId)
+{
+    gStyleResolvePart = partType;
+    gStyleResolveScrollbar = this;
+    RenderStyle* result = m_owner->getPseudoStyle(pseudoId, m_owner->style());
+    gStyleResolvePart = NoPart;
+    gStyleResolveScrollbar = 0;
+    return result;
+}
+
+void RenderScrollbar::updateScrollbarParts(RenderStyle* scrollbarStyle, bool destroy)
+{
+    updateScrollbarPart(ScrollbarBGPart, RenderStyle::SCROLLBAR, scrollbarStyle, destroy);
+    updateScrollbarPart(BackButtonStartPart, RenderStyle::SCROLLBAR_BUTTON, 0, destroy);
+    updateScrollbarPart(ForwardButtonStartPart, RenderStyle::SCROLLBAR_BUTTON, 0, destroy);
+    updateScrollbarPart(BackTrackPart, RenderStyle::SCROLLBAR_TRACK_PIECE, 0, destroy);
+    updateScrollbarPart(ThumbPart, RenderStyle::SCROLLBAR_THUMB, 0, destroy);
+    updateScrollbarPart(ForwardTrackPart, RenderStyle::SCROLLBAR_TRACK_PIECE, 0, destroy);
+    updateScrollbarPart(BackButtonEndPart, RenderStyle::SCROLLBAR_BUTTON, 0, destroy);
+    updateScrollbarPart(ForwardButtonEndPart, RenderStyle::SCROLLBAR_BUTTON, 0, destroy);
+    updateScrollbarPart(TrackBGPart, RenderStyle::SCROLLBAR_TRACK, 0, destroy);
+    
+    if (destroy)
+        return;
+
+    // See if the scrollbar's thickness changed.  If so, we need to mark our owning object as needing a layout.
+    bool isHorizontal = orientation() == HorizontalScrollbar;    
+    int oldThickness = isHorizontal ? height() : width();
+    int newThickness = 0;
+    RenderScrollbarPart* part = m_parts.get(ScrollbarBGPart);
+    if (part) {
+        part->layout();
+        newThickness = isHorizontal ? part->height() : part->width();
+    }
+    
+    if (newThickness != oldThickness) {
+        setFrameRect(IntRect(x(), y(), isHorizontal ? width() : newThickness, isHorizontal ? newThickness : height()));
+        m_owner->setChildNeedsLayout(true);
+    }
+}
+
+void RenderScrollbar::updateScrollbarPart(ScrollbarPart partType, RenderStyle::PseudoId pseudoId, RenderStyle* partStyle, bool destroy)
+{
+    if (!partStyle)
+        partStyle = getScrollbarPseudoStyle(partType, pseudoId);
+    
+    bool needRenderer = !destroy && partStyle && partStyle->display() != NONE && partStyle->visibility() == VISIBLE;
+    
+    RenderScrollbarPart* partRenderer = m_parts.get(partType);
+    if (!partRenderer && needRenderer) {
+        partRenderer = new (m_owner->renderArena()) RenderScrollbarPart(this, partType, m_owner->document());
+        m_parts.set(partType, partRenderer);
+    } else if (partRenderer && !needRenderer) {
+        m_parts.remove(partType);
+        partRenderer->destroy();
+        partRenderer = 0;
+    }
+    
+    if (partRenderer)
+        partRenderer->setStyle(partStyle);
+}
+
+void RenderScrollbar::paintPart(GraphicsContext* graphicsContext, ScrollbarPart partType, const IntRect& rect)
+{
+    RenderScrollbarPart* partRenderer = m_parts.get(partType);
+    if (!partRenderer)
+        return;
+
+    // Make sure our dimensions match the rect.
+    partRenderer->setPos(rect.x() - x(), rect.y() - y());
+    partRenderer->setWidth(rect.width());
+    partRenderer->setHeight(rect.height());
+
+    // Now do the paint.
+    RenderObject::PaintInfo paintInfo(graphicsContext, rect, PaintPhaseBlockBackground, false, 0, 0);
+    partRenderer->paint(paintInfo, x(), y());
+    paintInfo.phase = PaintPhaseChildBlockBackgrounds;
+    partRenderer->paint(paintInfo, x(), y());
+    paintInfo.phase = PaintPhaseFloat;
+    partRenderer->paint(paintInfo, x(), y());
+    paintInfo.phase = PaintPhaseForeground;
+    partRenderer->paint(paintInfo, x(), y());
+    paintInfo.phase = PaintPhaseOutline;
+    partRenderer->paint(paintInfo, x(), y());
+}
+
+IntRect RenderScrollbar::buttonRect(ScrollbarPart partType)
+{
+    RenderScrollbarPart* partRenderer = m_parts.get(partType);
+    if (!partRenderer)
+        return IntRect();
+        
+    partRenderer->layout();
+    
+    bool isHorizontal = orientation() == HorizontalScrollbar;
+    if (partType == BackButtonStartPart)
+        return IntRect(x(), y(), isHorizontal ? partRenderer->width() : width(), isHorizontal ? height() : partRenderer->height());
+    if (partType == ForwardButtonEndPart)
+        return IntRect(isHorizontal ? x() + width() - partRenderer->width() : x(),
+        
+                       isHorizontal ? y() : y() + height() - partRenderer->height(),
+                       isHorizontal ? partRenderer->width() : width(),
+                       isHorizontal ? height() : partRenderer->height());
+    
+    if (partType == ForwardButtonStartPart) {
+        IntRect previousButton = buttonRect(BackButtonStartPart);
+        return IntRect(isHorizontal ? x() + previousButton.width() : x(),
+                       isHorizontal ? y() : y() + previousButton.height(),
+                       isHorizontal ? partRenderer->width() : width(),
+                       isHorizontal ? height() : partRenderer->height());
+    }
+    
+    IntRect followingButton = buttonRect(ForwardButtonEndPart);
+    return IntRect(isHorizontal ? x() + width() - followingButton.width() - partRenderer->width() : x(),
+                   isHorizontal ? y() : y() + height() - followingButton.height() - partRenderer->height(),
+                   isHorizontal ? partRenderer->width() : width(),
+                   isHorizontal ? height() : partRenderer->height());
+}
+
+int RenderScrollbar::minimumThumbLength()
+{
+    RenderScrollbarPart* partRenderer = m_parts.get(ThumbPart);
+    if (!partRenderer)
+        return 0;    
+    partRenderer->layout();
+    return orientation() == HorizontalScrollbar ? partRenderer->width() : partRenderer->height();
+}
+
+}
diff --git a/WebCore/rendering/RenderScrollbar.h b/WebCore/rendering/RenderScrollbar.h
new file mode 100644 (file)
index 0000000..3c1b3e5
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2008 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 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 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 RenderScrollbar_h
+#define RenderScrollbar_h
+
+#include "Scrollbar.h"
+#include "RenderStyle.h"
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+
+class RenderObject;
+class RenderScrollbarPart;
+class RenderStyle;
+
+class RenderScrollbar : public Scrollbar {
+protected:
+    RenderScrollbar(ScrollbarClient*, ScrollbarOrientation, RenderStyle*, RenderObject*);
+
+public:
+    friend class Scrollbar;
+    static PassRefPtr<Scrollbar> createCustomScrollbar(ScrollbarClient*, ScrollbarOrientation, RenderStyle*, RenderObject*);
+    virtual ~RenderScrollbar();
+
+    void updateScrollbarParts(RenderStyle* = 0, bool destroy = false);
+
+    static ScrollbarPart partForStyleResolve();
+    static RenderScrollbar* scrollbarForStyleResolve();
+
+    virtual void styleChanged() { updateScrollbarParts(); }
+
+    RenderObject* owningRenderer() const { return m_owner; }
+
+    void paintPart(GraphicsContext*, ScrollbarPart, const IntRect&);
+
+    IntRect buttonRect(ScrollbarPart);
+    
+    int minimumThumbLength();
+
+private:
+    RenderStyle* getScrollbarPseudoStyle(ScrollbarPart, RenderStyle::PseudoId);
+    void updateScrollbarPart(ScrollbarPart, RenderStyle::PseudoId, RenderStyle*, bool destroy);
+
+    RenderObject* m_owner;
+    HashMap<unsigned, RenderScrollbarPart*> m_parts;
+};
+
+} // namespace WebCore
+
+#endif // RenderScrollbar_h
diff --git a/WebCore/rendering/RenderScrollbarPart.cpp b/WebCore/rendering/RenderScrollbarPart.cpp
new file mode 100644 (file)
index 0000000..d32a32f
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2008 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 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 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 "RenderScrollbarPart.h"
+#include "RenderScrollbar.h"
+#include "RenderScrollbarTheme.h"
+
+using namespace std;
+
+namespace WebCore {
+
+RenderScrollbarPart::RenderScrollbarPart(RenderScrollbar* scrollbar, ScrollbarPart part, Node* node)
+    : RenderBlock(node)
+    , m_scrollbar(scrollbar)
+    , m_part(part)
+{
+}
+
+RenderScrollbarPart::~RenderScrollbarPart()
+{
+}
+
+void RenderScrollbarPart::layout()
+{
+    setPos(0, 0); // We don't worry about positioning ourselves.  We're just determining our minimum width/height.
+    if (m_scrollbar->orientation() == HorizontalScrollbar)
+        layoutHorizontalPart();
+    else
+        layoutVerticalPart();
+
+    m_overflowWidth = max(m_width, m_overflowWidth);
+    m_overflowHeight = max(m_height, m_overflowHeight);
+    
+    setNeedsLayout(false);
+}
+
+void RenderScrollbarPart::layoutHorizontalPart()
+{
+    if (m_part == ScrollbarBGPart) {
+        m_width = m_scrollbar->width();
+        computeScrollbarHeight();
+    } else {
+        computeScrollbarWidth();
+        m_height = m_scrollbar->height();
+    }
+}
+
+void RenderScrollbarPart::layoutVerticalPart()
+{
+    if (m_part == ScrollbarBGPart) {
+        computeScrollbarWidth();
+        m_height = m_scrollbar->height();
+    } else {
+        m_width = m_scrollbar->width();
+        computeScrollbarHeight();
+    } 
+}
+
+static int calcScrollbarThicknessUsing(const Length& l, int containingLength)
+{
+    if (l.isIntrinsicOrAuto())
+        return ScrollbarTheme::nativeTheme()->scrollbarThickness();
+    return l.calcMinValue(containingLength);
+}
+
+void RenderScrollbarPart::computeScrollbarWidth()
+{
+    int visibleSize = m_scrollbar->owningRenderer()->width() - m_scrollbar->owningRenderer()->borderLeft() - m_scrollbar->owningRenderer()->borderRight();
+    int width = calcScrollbarThicknessUsing(style()->width(), visibleSize);
+    int minWidth = calcScrollbarThicknessUsing(style()->minWidth(), visibleSize);
+    int maxWidth = style()->maxWidth().isUndefined() ? width : calcScrollbarThicknessUsing(style()->maxWidth(), visibleSize);
+    m_width = max(minWidth, min(maxWidth, width));
+}
+
+void RenderScrollbarPart::computeScrollbarHeight()
+{
+    int visibleSize = m_scrollbar->owningRenderer()->height() -  m_scrollbar->owningRenderer()->borderTop() - m_scrollbar->owningRenderer()->borderBottom();
+    int height = calcScrollbarThicknessUsing(style()->height(), visibleSize);
+    int minHeight = calcScrollbarThicknessUsing(style()->minHeight(), visibleSize);
+    int maxHeight = style()->maxHeight().isUndefined() ? height : calcScrollbarThicknessUsing(style()->maxHeight(), visibleSize);
+    m_height = max(minHeight, min(maxHeight, height));
+
+}
+
+void RenderScrollbarPart::calcPrefWidths()
+{
+    if (!prefWidthsDirty())
+        return;
+    
+    m_minPrefWidth = m_maxPrefWidth = 0;
+
+    setPrefWidthsDirty(false);
+}
+
+void RenderScrollbarPart::setStyle(const RenderStyle* s)
+{
+    RenderBlock::setStyle(s);
+    setInline(false);
+    setPositioned(false);
+    setFloating(false);
+    setHasOverflowClip(false);
+}
+
+}
diff --git a/WebCore/rendering/RenderScrollbarPart.h b/WebCore/rendering/RenderScrollbarPart.h
new file mode 100644 (file)
index 0000000..1d9f179
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2008 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 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 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 RenderScrollbarPart_h
+#define RenderScrollbarPart_h
+
+#include "RenderBlock.h"
+#include "ScrollTypes.h"
+
+namespace WebCore {
+
+class RenderScrollbar;
+
+class RenderScrollbarPart : public RenderBlock {
+public:
+    RenderScrollbarPart(RenderScrollbar*, ScrollbarPart, Node*);
+    virtual ~RenderScrollbarPart();
+
+    virtual const char* renderName() const { return "RenderScrollbarPart"; }
+    
+    virtual bool requiresLayer() { return false; }
+
+    virtual void layout();
+    virtual void calcPrefWidths();
+    
+    virtual void setStyle(const RenderStyle*);
+
+private:
+    void layoutHorizontalPart();
+    void layoutVerticalPart();
+
+    void computeScrollbarWidth();
+    void computeScrollbarHeight();
+    
+    RenderScrollbar* m_scrollbar;
+    ScrollbarPart m_part;
+};
+
+} // namespace WebCore
+
+#endif // RenderScrollbarPart_h
diff --git a/WebCore/rendering/RenderScrollbarTheme.cpp b/WebCore/rendering/RenderScrollbarTheme.cpp
new file mode 100644 (file)
index 0000000..f24308e
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2008 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 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 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 "RenderScrollbarTheme.h"
+#include "RenderScrollbar.h"
+
+namespace WebCore {
+
+RenderScrollbarTheme* RenderScrollbarTheme::renderScrollbarTheme()
+{
+    static RenderScrollbarTheme theme;
+    return &theme;
+}
+
+void RenderScrollbarTheme::buttonSizesAlongTrackAxis(Scrollbar* scrollbar, int& beforeSize, int& afterSize)
+{
+    IntRect firstButton = backButtonRect(scrollbar, BackButtonStartPart);
+    IntRect secondButton = forwardButtonRect(scrollbar, ForwardButtonStartPart);
+    IntRect thirdButton = backButtonRect(scrollbar, BackButtonEndPart);
+    IntRect fourthButton = forwardButtonRect(scrollbar, ForwardButtonEndPart);
+    if (scrollbar->orientation() == HorizontalScrollbar) {
+        beforeSize = firstButton.width() + secondButton.width();
+        afterSize = thirdButton.width() + fourthButton.width();
+    } else {
+        beforeSize = firstButton.height() + secondButton.height();
+        afterSize = thirdButton.height() + fourthButton.height();
+    }
+}
+
+bool RenderScrollbarTheme::hasButtons(Scrollbar* scrollbar)
+{
+    int startSize;
+    int endSize;
+    buttonSizesAlongTrackAxis(scrollbar, startSize, endSize);
+    return (startSize + endSize) <= (scrollbar->orientation() == HorizontalScrollbar ? scrollbar->width() : scrollbar->height());
+}
+
+bool RenderScrollbarTheme::hasThumb(Scrollbar* scrollbar)
+{
+    return trackLength(scrollbar) - thumbLength(scrollbar) >= 0;
+}
+
+int RenderScrollbarTheme::minimumThumbLength(Scrollbar* scrollbar)
+{
+    return static_cast<RenderScrollbar*>(scrollbar)->minimumThumbLength();
+}
+
+IntRect RenderScrollbarTheme::backButtonRect(Scrollbar* scrollbar, ScrollbarPart partType, bool painting)
+{
+    return static_cast<RenderScrollbar*>(scrollbar)->buttonRect(partType);
+}
+
+IntRect RenderScrollbarTheme::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart partType, bool painting)
+{
+    return static_cast<RenderScrollbar*>(scrollbar)->buttonRect(partType);
+}
+
+IntRect RenderScrollbarTheme::trackRect(Scrollbar* scrollbar, bool painting)
+{
+    if (!hasButtons(scrollbar))
+        return scrollbar->frameRect();
+    int startLength;
+    int endLength;
+    buttonSizesAlongTrackAxis(scrollbar, startLength, endLength);
+    int totalLength = startLength + endLength;
+    if (scrollbar->orientation() == HorizontalScrollbar)
+        return IntRect(scrollbar->x() + startLength, scrollbar->y(), scrollbar->width() - totalLength, scrollbar->height());
+    return IntRect(scrollbar->x(), scrollbar->y() + startLength, scrollbar->width(), scrollbar->height() - totalLength);
+}
+
+void RenderScrollbarTheme::paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& cornerRect)
+{
+    // FIXME: Implement.
+    context->fillRect(cornerRect, Color::white);
+}
+
+void RenderScrollbarTheme::paintScrollbarBackground(GraphicsContext* context, Scrollbar* scrollbar)
+{
+    static_cast<RenderScrollbar*>(scrollbar)->paintPart(context, ScrollbarBGPart, scrollbar->frameRect());
+}
+
+void RenderScrollbarTheme::paintTrackBackground(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect)
+{
+    static_cast<RenderScrollbar*>(scrollbar)->paintPart(context, TrackBGPart, rect);
+}
+
+void RenderScrollbarTheme::paintTrackPiece(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart part)
+{
+    static_cast<RenderScrollbar*>(scrollbar)->paintPart(context, part, rect);
+}
+
+void RenderScrollbarTheme::paintButton(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart part)
+{
+    static_cast<RenderScrollbar*>(scrollbar)->paintPart(context, part, rect);
+}
+
+void RenderScrollbarTheme::paintThumb(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect)
+{
+    static_cast<RenderScrollbar*>(scrollbar)->paintPart(context, ThumbPart, rect);
+}
+
+}
diff --git a/WebCore/rendering/RenderScrollbarTheme.h b/WebCore/rendering/RenderScrollbarTheme.h
new file mode 100644 (file)
index 0000000..6a187fc
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2008 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 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 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 RenderScrollbarTheme_h
+#define RenderScrollbarTheme_h
+
+#include "ScrollbarThemeComposite.h"
+
+namespace WebCore {
+
+class PlatformMouseEvent;
+class Scrollbar;
+class ScrollView;
+
+class RenderScrollbarTheme : public ScrollbarThemeComposite {
+public:
+    virtual ~RenderScrollbarTheme() {};
+    
+    virtual int scrollbarThickness(ScrollbarControlSize controlSize) { return ScrollbarTheme::nativeTheme()->scrollbarThickness(controlSize); }
+
+    virtual ScrollbarButtonsPlacement buttonsPlacement() const { return ScrollbarButtonsDoubleBoth; }
+
+    virtual bool supportsControlTints() const { return true; }
+
+    virtual void paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& cornerRect);
+
+    virtual bool shouldCenterOnThumb(Scrollbar* scrollbar, const PlatformMouseEvent& event) { return ScrollbarTheme::nativeTheme()->shouldCenterOnThumb(scrollbar, event); }
+    
+    virtual double initialAutoscrollTimerDelay() { return ScrollbarTheme::nativeTheme()->initialAutoscrollTimerDelay(); }
+    virtual double autoscrollTimerDelay() { return ScrollbarTheme::nativeTheme()->autoscrollTimerDelay(); }
+
+    virtual void registerScrollbar(Scrollbar* scrollbar) { return ScrollbarTheme::nativeTheme()->registerScrollbar(scrollbar); }
+    virtual void unregisterScrollbar(Scrollbar* scrollbar) { return ScrollbarTheme::nativeTheme()->unregisterScrollbar(scrollbar); }
+
+    virtual int minimumThumbLength(Scrollbar*);
+
+    void buttonSizesAlongTrackAxis(Scrollbar* scrollbar, int& beforeSize, int& afterSize);
+    
+    static RenderScrollbarTheme* renderScrollbarTheme();
+
+protected:
+    virtual bool hasButtons(Scrollbar*);
+    virtual bool hasThumb(Scrollbar*);
+
+    virtual IntRect backButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
+    virtual IntRect forwardButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
+    virtual IntRect trackRect(Scrollbar*, bool painting = false);
+    
+    virtual void paintScrollbarBackground(GraphicsContext*, Scrollbar*);    
+    virtual void paintTrackBackground(GraphicsContext*, Scrollbar*, const IntRect&);
+    virtual void paintTrackPiece(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart);
+    virtual void paintButton(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart);
+    virtual void paintThumb(GraphicsContext*, Scrollbar*, const IntRect&);
+
+};
+
+} // namespace WebCore
+
+#endif // RenderScrollbarTheme_h
index 2e86b9f..1331e68 100644 (file)
@@ -109,7 +109,8 @@ public:
     enum PseudoId { NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER, SELECTION, FIRST_LINE_INHERITED, FILE_UPLOAD_BUTTON, INPUT_PLACEHOLDER,
                     SLIDER_THUMB, SEARCH_CANCEL_BUTTON, SEARCH_DECORATION, SEARCH_RESULTS_DECORATION, SEARCH_RESULTS_BUTTON, MEDIA_CONTROLS_PANEL,
                     MEDIA_CONTROLS_PLAY_BUTTON, MEDIA_CONTROLS_MUTE_BUTTON, MEDIA_CONTROLS_TIMELINE, MEDIA_CONTROLS_TIME_DISPLAY,
-                    MEDIA_CONTROLS_SEEK_BACK_BUTTON, MEDIA_CONTROLS_SEEK_FORWARD_BUTTON , MEDIA_CONTROLS_FULLSCREEN_BUTTON };
+                    MEDIA_CONTROLS_SEEK_BACK_BUTTON, MEDIA_CONTROLS_SEEK_FORWARD_BUTTON , MEDIA_CONTROLS_FULLSCREEN_BUTTON,
+                    SCROLLBAR, SCROLLBAR_THUMB, SCROLLBAR_BUTTON, SCROLLBAR_TRACK, SCROLLBAR_TRACK_PIECE, SCROLLBAR_CORNER };
     static const int FIRST_INTERNAL_PSEUDOID = FILE_UPLOAD_BUTTON;
 
     void ref() { m_ref++; }