Crash in RenderTableCell::borderTop() due to custom scrollbars after r124168
https://bugs.webkit.org/show_bug.cgi?id=93903

Reviewed by Tony Chang.

Source/WebCore:

r124168 changed when we create scrollbars so that it happens (rightly) at style change time.
However the RenderScrollbar code assumes that any overflow: scroll RenderScrollbar would be
created at layout time as it directly tries to layout to scrollbar parts. The big issues with
the move is that the first style change operates on a detached renderer which means that we
could crash in some situation.

Test: scrollbars/custom-scrollbar-table-cell.html

* rendering/RenderScrollbarPart.cpp:
(WebCore::RenderScrollbarPart::computeScrollbarWidth):
(WebCore::RenderScrollbarPart::computeScrollbarHeight):
Fixed the crash by using style information instead of calling the renderer. This is guaranteed
to be safe but it also means that custom scrollbars sizing is not right on table cells with
collapsing borders. The existing logic was querying layout information at style change so I
wouldn't bet on it working properly anyway.

LayoutTests:

* scrollbars/custom-scrollbar-table-cell-expected.png: Added.
* scrollbars/custom-scrollbar-table-cell-expected.txt: Added.
* scrollbars/custom-scrollbar-table-cell.html: Added.


git-svn-id: svn://svn.chromium.org/blink/trunk@126591 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/third_party/WebKit/LayoutTests/scrollbars/custom-scrollbar-table-cell.html b/third_party/WebKit/LayoutTests/scrollbars/custom-scrollbar-table-cell.html
new file mode 100644
index 0000000..ff03dd9
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/scrollbars/custom-scrollbar-table-cell.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+::-webkit-scrollbar {
+    width: 16px;
+    height: 16px;
+}
+
+::-webkit-scrollbar-track
+{
+    background-color: #E3E3E3;
+}
+
+::-webkit-scrollbar-thumb
+{
+    background: black;
+}
+
+.scroll-row {
+    display: table-row;
+}
+
+.scroll-cell {
+    display: table-cell;
+    overflow: scroll;
+    width: 50px;
+    height: 50px;
+}
+
+.overflowing {
+    width: 200px;
+    height: 200px;
+}
+</style>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText(true);
+</script>
+</head>
+<body>
+<!--
+    Bug 93903: Crash in RenderTableCell::borderTop() due to custom scrollbars after r124168
+    This test has PASSED if there are 2 grey custom scrollbars with a black thumb on each div below.
+    Note that currently the right scrollbar is missing due to https://bugs.webkit.org/show_bug.cgi?id=94054
+-->
+<div class="scroll-cell"><div class="overflowing"></div></div>
+<div class="scroll-row"><div class="scroll-cell"><div class="overflowing"></div></div></div>
+</body>
+</html>