Commit ee645833 authored by tony@chromium.org's avatar tony@chromium.org

2010-08-05 Tony Chang <tony@chromium.org>

        Reviewed by David Hyatt.

        Fix a crash when a hidden iframe with a custom scrollbar finishes loading an image.
        https://bugs.webkit.org/show_bug.cgi?id=42724

        * scrollbars/hidden-iframe-scrollbar-crash2.html: Added.
        * scrollbars/resources/hidden-iframe-scrollbar-crash2.html: Added.
2010-08-05  Tony Chang  <tony@chromium.org>

        Reviewed by David Hyatt.

        Fix a crash when a hidden iframe with a custom scrollbar finishes loading an image.
        https://bugs.webkit.org/show_bug.cgi?id=42724

        Test: scrollbars/hidden-iframe-scrollbar-crash2.html

        * page/FrameView.cpp:
        (WebCore::FrameView::createScrollbar):
        * rendering/RenderScrollbar.cpp:
        (WebCore::RenderScrollbar::createCustomScrollbar): Pass in Frame
        (WebCore::RenderScrollbar::RenderScrollbar): Pass in Frame
        (WebCore::RenderScrollbar::owningRenderer): Use the frame to get the RenderBox
        (WebCore::RenderScrollbar::getScrollbarPseudoStyle):
        (WebCore::RenderScrollbar::updateScrollbarParts):
        (WebCore::RenderScrollbar::updateScrollbarPart):
        * rendering/RenderScrollbar.h:
        * rendering/RenderScrollbarPart.cpp:
        (WebCore::RenderScrollbarPart::computeScrollbarWidth): null check
        (WebCore::RenderScrollbarPart::computeScrollbarHeight): null check

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64780 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1306d061
2010-08-05 Tony Chang <tony@chromium.org>
Reviewed by David Hyatt.
Fix a crash when a hidden iframe with a custom scrollbar finishes loading an image.
https://bugs.webkit.org/show_bug.cgi?id=42724
* scrollbars/hidden-iframe-scrollbar-crash2.html: Added.
* scrollbars/resources/hidden-iframe-scrollbar-crash2.html: Added.
2010-08-05 Ilya Tikhonovsky <loislo@chromium.org>
Unreviewed build fix for Chromium.
This tests to make sure that an iframe with custom scrollbars that starts an image load and is hidden before the image load is complete doesn't crash when the image load completes. The test passes if it does not crash.
PASSED
<style>
::-webkit-scrollbar {
background:#f0ebe2
}
::-webkit-scrollbar-thumb:vertical {
-webkit-border-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAPCAYAAADtc08vAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOTQAADpwB3vacVwAAAAd0SU1FB9oFEhUeDmSV9s4AAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAABoUlEQVQoz62Ty05TURSGv717zj4HoUk1qabAgYZWUkO0Rk0IiWFiookjn0CfyVdg6BvITB00TkzFC1VabC1yEYJgaWjP2RcnSBBx0OA3WVnJWv8a/OsXnOJT9YX7sbNOt7OHTvoA+CokncmSi4qMF8ri5Pxx8+Vjxa01a/ieIpcvcTE7hgqG0FoTH3bY391me7OFtZqZ2/dIZ7LiWKC+9NK1Gu+ZKJaZnL6J0THWaKzRJHEPazTGWqQQHPzcp7lS5c78I9KZrPAqiwturVkjKsyQn76FsQk4x184i9aaIFRMFK+z9Po5ADKJ+6Q8n6lrc3DG3mmstQyPpJEpj/VWzck4jokKZQYh6ffIRUW22itIqzWXx6YGEnDOEg4Ns7e7wbkRi8+eursPn6CCCzhjMC7BGY215k8Xjlz5XVU4wnL1FVJ6Ht+/rQ52VUh6h10yl3JIpRTtxtuBBPwgZKNd50p0FemrAKMTVpcrJ/7y30gp6R50sEYzOlkScu7+YzGeL9FufKD5+Q1SpkCcoSQknh/Q78V8rb/jxuyD/5iF86TxF8VV4SSfiBybAAAAAElFTkSuQmCC') 7 0 7 0 / 7px 0 7px 0 round;background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAJCAYAAAA7KqwyAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOTQAADpwB3vacVwAAAAd0SU1FB9oFEhUgGNGEWOIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAWElEQVQoz2PcsbL/v3tYPsO/f/8Y/v/9y/Dv/x+Gf38h+O/f3wy/f36Hsv+g0JxcfAxnj25jYGHAAi6d3IVNmEFWUQNDDKsBeuZuOF2ADpgYKASjXqCCFwDpmWlwnmaGdAAAAABJRU5ErkJggg==') left center no-repeat, url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAABCAYAAADXeS5fAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOTQAADpwB3vacVwAAAAd0SU1FB9oFEhUfFffrDmMAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAQElEQVQI11XFsRFAUBRE0Ss0AlWpQB1qUYcGjAak6jH/v90VO8kZrmPPsm4kJhJKJypsYRW9vViFVL/Haea5Tz6Sain0ymD28wAAAABJRU5ErkJggg==');
}
</style>
<body>
<iframe id="iframe" src="resources/hidden-iframe-scrollbar-crash2.html" width="50px" onload="load()"></iframe>
<p>This tests to make sure that an iframe with custom scrollbars that starts
an image load and is hidden before the image load is complete doesn't crash
when the image load completes. The test passes if it does not crash.</p>
</body>
<script>
function load()
{
var iframe = document.getElementById("iframe");
var win = iframe.contentWindow;
var img = win.document.getElementById("i");
img.src = "resizer.png";
}
if (window.layoutTestController) {
layoutTestController.waitUntilDone();
layoutTestController.dumpAsText();
}
</script>
<html>
<body><p>
This is some text to force a scrollbar to appear.
This is some text to force a scrollbar to appear.
This is some text to force a scrollbar to appear.
</p>
<img id="i" onbeforeload="beforeload()" onload="pass()">
</body>
<script>
function beforeload()
{
setTimeout(function() {
var win = window.parent;
win.document.getElementById("iframe").style.display = "none";
});
return true;
}
function pass()
{
var win = window.parent;
win.document.getElementById("iframe").style.display = "";
win.document.body.appendChild(document.createTextNode("PASSED"));
if (window.layoutTestController)
layoutTestController.notifyDone();
}
</script>
</html>
2010-08-05 Tony Chang <tony@chromium.org>
Reviewed by David Hyatt.
Fix a crash when a hidden iframe with a custom scrollbar finishes loading an image.
https://bugs.webkit.org/show_bug.cgi?id=42724
Test: scrollbars/hidden-iframe-scrollbar-crash2.html
* page/FrameView.cpp:
(WebCore::FrameView::createScrollbar):
* rendering/RenderScrollbar.cpp:
(WebCore::RenderScrollbar::createCustomScrollbar): Pass in Frame
(WebCore::RenderScrollbar::RenderScrollbar): Pass in Frame
(WebCore::RenderScrollbar::owningRenderer): Use the frame to get the RenderBox
(WebCore::RenderScrollbar::getScrollbarPseudoStyle):
(WebCore::RenderScrollbar::updateScrollbarParts):
(WebCore::RenderScrollbar::updateScrollbarPart):
* rendering/RenderScrollbar.h:
* rendering/RenderScrollbarPart.cpp:
(WebCore::RenderScrollbarPart::computeScrollbarWidth): null check
(WebCore::RenderScrollbarPart::computeScrollbarHeight): null check
2010-08-05 Yong Li <yoli@rim.com>
Reviewed by Adam Treat.
......@@ -409,7 +409,7 @@ PassRefPtr<Scrollbar> FrameView::createScrollbar(ScrollbarOrientation orientatio
// If we have an owning iframe/frame element, then it can set the custom scrollbar also.
RenderPart* frameRenderer = m_frame->ownerRenderer();
if (frameRenderer && frameRenderer->style()->hasPseudoStyle(SCROLLBAR))
return RenderScrollbar::createCustomScrollbar(this, orientation, frameRenderer);
return RenderScrollbar::createCustomScrollbar(this, orientation, 0, m_frame.get());
// Nobody set a custom style, so we just use a native scrollbar.
return ScrollView::createScrollbar(orientation);
......
......@@ -26,19 +26,22 @@
#include "config.h"
#include "RenderScrollbar.h"
#include "Frame.h"
#include "RenderPart.h"
#include "RenderScrollbarPart.h"
#include "RenderScrollbarTheme.h"
namespace WebCore {
PassRefPtr<Scrollbar> RenderScrollbar::createCustomScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, RenderBox* renderer)
PassRefPtr<Scrollbar> RenderScrollbar::createCustomScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, RenderBox* renderer, Frame* owningFrame)
{
return adoptRef(new RenderScrollbar(client, orientation, renderer));
return adoptRef(new RenderScrollbar(client, orientation, renderer, owningFrame));
}
RenderScrollbar::RenderScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, RenderBox* renderer)
RenderScrollbar::RenderScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, RenderBox* renderer, Frame* owningFrame)
: Scrollbar(client, orientation, RegularScrollbar, RenderScrollbarTheme::renderScrollbarTheme())
, m_owner(renderer)
, m_owningFrame(owningFrame)
{
// FIXME: We need to do this because RenderScrollbar::styleChanged is called as soon as the scrollbar is created.
......@@ -57,6 +60,15 @@ RenderScrollbar::~RenderScrollbar()
ASSERT(m_parts.isEmpty());
}
RenderBox* RenderScrollbar::owningRenderer() const
{
if (m_owningFrame) {
RenderBox* currentRenderer = m_owningFrame->ownerRenderer();
return currentRenderer;
}
return m_owner;
}
void RenderScrollbar::setParent(ScrollView* parent)
{
Scrollbar::setParent(parent);
......@@ -135,7 +147,7 @@ PassRefPtr<RenderStyle> RenderScrollbar::getScrollbarPseudoStyle(ScrollbarPart p
s_styleResolvePart = partType;
s_styleResolveScrollbar = this;
RefPtr<RenderStyle> result = m_owner->getUncachedPseudoStyle(pseudoId, m_owner->style());
RefPtr<RenderStyle> result = owningRenderer()->getUncachedPseudoStyle(pseudoId, owningRenderer()->style());
s_styleResolvePart = NoPart;
s_styleResolveScrollbar = 0;
return result;
......@@ -168,7 +180,7 @@ void RenderScrollbar::updateScrollbarParts(bool destroy)
if (newThickness != oldThickness) {
setFrameRect(IntRect(x(), y(), isHorizontal ? width() : newThickness, isHorizontal ? newThickness : height()));
m_owner->setChildNeedsLayout(true);
owningRenderer()->setChildNeedsLayout(true);
}
}
......@@ -231,7 +243,7 @@ void RenderScrollbar::updateScrollbarPart(ScrollbarPart partType, bool destroy)
RenderScrollbarPart* partRenderer = m_parts.get(partType);
if (!partRenderer && needRenderer) {
partRenderer = new (m_owner->renderArena()) RenderScrollbarPart(m_owner->document(), this, partType);
partRenderer = new (owningRenderer()->renderArena()) RenderScrollbarPart(owningRenderer()->document(), this, partType);
m_parts.set(partType, partRenderer);
} else if (partRenderer && !needRenderer) {
m_parts.remove(partType);
......
......@@ -32,23 +32,24 @@
namespace WebCore {
class Frame;
class RenderBox;
class RenderScrollbarPart;
class RenderStyle;
class RenderScrollbar : public Scrollbar {
protected:
RenderScrollbar(ScrollbarClient*, ScrollbarOrientation, RenderBox*);
RenderScrollbar(ScrollbarClient*, ScrollbarOrientation, RenderBox*, Frame*);
public:
friend class Scrollbar;
static PassRefPtr<Scrollbar> createCustomScrollbar(ScrollbarClient*, ScrollbarOrientation, RenderBox*);
static PassRefPtr<Scrollbar> createCustomScrollbar(ScrollbarClient*, ScrollbarOrientation, RenderBox*, Frame* owningFrame = 0);
virtual ~RenderScrollbar();
static ScrollbarPart partForStyleResolve();
static RenderScrollbar* scrollbarForStyleResolve();
RenderBox* owningRenderer() const { return m_owner; }
RenderBox* owningRenderer() const;
void clearOwningRenderer() { m_owner = 0; }
void paintPart(GraphicsContext*, ScrollbarPart, const IntRect&);
......@@ -78,6 +79,7 @@ private:
void updateScrollbarPart(ScrollbarPart, bool destroy = false);
RenderBox* m_owner;
Frame* m_owningFrame;
HashMap<unsigned, RenderScrollbarPart*> m_parts;
};
......
......@@ -86,6 +86,8 @@ static int calcScrollbarThicknessUsing(const Length& l, int containingLength)
void RenderScrollbarPart::computeScrollbarWidth()
{
if (!m_scrollbar->owningRenderer())
return;
int visibleSize = m_scrollbar->owningRenderer()->width() - m_scrollbar->owningRenderer()->borderLeft() - m_scrollbar->owningRenderer()->borderRight();
int w = calcScrollbarThicknessUsing(style()->width(), visibleSize);
int minWidth = calcScrollbarThicknessUsing(style()->minWidth(), visibleSize);
......@@ -99,6 +101,8 @@ void RenderScrollbarPart::computeScrollbarWidth()
void RenderScrollbarPart::computeScrollbarHeight()
{
if (!m_scrollbar->owningRenderer())
return;
int visibleSize = m_scrollbar->owningRenderer()->height() - m_scrollbar->owningRenderer()->borderTop() - m_scrollbar->owningRenderer()->borderBottom();
int h = calcScrollbarThicknessUsing(style()->height(), visibleSize);
int minHeight = calcScrollbarThicknessUsing(style()->minHeight(), visibleSize);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment