Commit c01fb23a authored by hyatt@apple.com's avatar hyatt@apple.com

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

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

        Refactor contents size and scroll offset to be cross-platform.  Reduce further the number
        of platform-specific methods required of ScrollView implementations.

        Reviewed by Tim Hatcher

        * dom/MouseRelatedEvent.cpp:
        (WebCore::contentsX):
        (WebCore::contentsY):
        * html/HTMLBodyElement.cpp:
        (WebCore::HTMLBodyElement::scrollLeft):
        (WebCore::HTMLBodyElement::setScrollLeft):
        (WebCore::HTMLBodyElement::scrollTop):
        (WebCore::HTMLBodyElement::setScrollTop):
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::saveScrollPositionAndViewStateToItem):
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::scrollX):
        (WebCore::DOMWindow::scrollY):
        * page/EventHandler.cpp:
        (WebCore::EventHandler::hitTestResultAtPoint):
        * page/FrameView.cpp:
        (WebCore::FrameView::scrollTo):
        (WebCore::FrameView::windowClipRect):
        * platform/ScrollView.cpp:
        (WebCore::ScrollView::visibleContentRect):
        (WebCore::ScrollView::contentsSize):
        (WebCore::ScrollView::platformContentsSize):
        * platform/ScrollView.h:
        (WebCore::ScrollView::scrollPosition):
        (WebCore::ScrollView::scrollOffset):
        (WebCore::ScrollView::scrollX):
        (WebCore::ScrollView::scrollY):
        (WebCore::ScrollView::contentsWidth):
        (WebCore::ScrollView::contentsHeight):
        * platform/gtk/ScrollViewGtk.cpp:
        (WebCore::ScrollView::ScrollViewPrivate::adjustmentChanged):
        (WebCore::ScrollView::setGtkAdjustments):
        (WebCore::ScrollView::resizeContents):
        (WebCore::ScrollView::contentsWidth):
        (WebCore::ScrollView::contentsHeight):
        (WebCore::ScrollView::scrollOffset):
        (WebCore::ScrollView::maximumScroll):
        (WebCore::ScrollView::scrollBy):
        (WebCore::ScrollView::suppressScrollbars):
        (WebCore::ScrollView::setHScrollbarMode):
        (WebCore::ScrollView::setVScrollbarMode):
        (WebCore::ScrollView::setScrollbarsMode):
        (WebCore::ScrollView::setFrameGeometry):
        (WebCore::ScrollView::updateScrollbars):
        * platform/mac/ScrollViewMac.mm:
        (WebCore::ScrollView::platformContentsSize):
        (WebCore::ScrollView::scrollBy):
        * platform/mac/WidgetMac.mm:
        (WebCore::Widget::convertFromContainingWindow):
        (WebCore::Widget::convertToContainingWindow):
        * platform/qt/ScrollViewQt.cpp:
        (WebCore::ScrollView::ScrollViewPrivate::valueChanged):
        (WebCore::ScrollView::resizeContents):
        (WebCore::ScrollView::setFrameGeometry):
        (WebCore::ScrollView::scrollOffset):
        (WebCore::ScrollView::maximumScroll):
        (WebCore::ScrollView::scrollBy):
        (WebCore::ScrollView::setHScrollbarMode):
        (WebCore::ScrollView::setVScrollbarMode):
        (WebCore::ScrollView::setScrollbarsMode):
        (WebCore::ScrollView::updateScrollbars):
        * platform/win/ScrollViewWin.cpp:
        (WebCore::ScrollView::ScrollViewPrivate::valueChanged):
        (WebCore::ScrollView::ScrollViewPrivate::setAllowsScrolling):
        (WebCore::ScrollView::resizeContents):
        (WebCore::ScrollView::setFrameGeometry):
        (WebCore::ScrollView::scrollOffset):
        (WebCore::ScrollView::maximumScroll):
        (WebCore::ScrollView::scrollBy):
        (WebCore::ScrollView::setHScrollbarMode):
        (WebCore::ScrollView::setVScrollbarMode):
        (WebCore::ScrollView::setScrollbarsMode):
        (WebCore::ScrollView::updateScrollbars):
        * platform/wx/ScrollViewWx.cpp:
        (WebCore::ScrollView::platformVisibleContentRect):
        (WebCore::ScrollView::platformContentsSize):
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::nodeAtPoint):
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::scrollRectToVisible):
        (WebCore::RenderLayer::calculateClipRects):
        (WebCore::RenderLayer::calculateRects):
        * rendering/RenderView.cpp:
        (WebCore::RenderView::absolutePosition):
        (WebCore::RenderView::computeAbsoluteRepaintRect):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@36925 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0fedb62f
2008-09-25 David Hyatt <hyatt@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=21129
Refactor contents size and scroll offset to be cross-platform. Reduce further the number
of platform-specific methods required of ScrollView implementations.
Reviewed by Tim Hatcher
* dom/MouseRelatedEvent.cpp:
(WebCore::contentsX):
(WebCore::contentsY):
* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::scrollLeft):
(WebCore::HTMLBodyElement::setScrollLeft):
(WebCore::HTMLBodyElement::scrollTop):
(WebCore::HTMLBodyElement::setScrollTop):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::saveScrollPositionAndViewStateToItem):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::scrollX):
(WebCore::DOMWindow::scrollY):
* page/EventHandler.cpp:
(WebCore::EventHandler::hitTestResultAtPoint):
* page/FrameView.cpp:
(WebCore::FrameView::scrollTo):
(WebCore::FrameView::windowClipRect):
* platform/ScrollView.cpp:
(WebCore::ScrollView::visibleContentRect):
(WebCore::ScrollView::contentsSize):
(WebCore::ScrollView::platformContentsSize):
* platform/ScrollView.h:
(WebCore::ScrollView::scrollPosition):
(WebCore::ScrollView::scrollOffset):
(WebCore::ScrollView::scrollX):
(WebCore::ScrollView::scrollY):
(WebCore::ScrollView::contentsWidth):
(WebCore::ScrollView::contentsHeight):
* platform/gtk/ScrollViewGtk.cpp:
(WebCore::ScrollView::ScrollViewPrivate::adjustmentChanged):
(WebCore::ScrollView::setGtkAdjustments):
(WebCore::ScrollView::resizeContents):
(WebCore::ScrollView::contentsWidth):
(WebCore::ScrollView::contentsHeight):
(WebCore::ScrollView::scrollOffset):
(WebCore::ScrollView::maximumScroll):
(WebCore::ScrollView::scrollBy):
(WebCore::ScrollView::suppressScrollbars):
(WebCore::ScrollView::setHScrollbarMode):
(WebCore::ScrollView::setVScrollbarMode):
(WebCore::ScrollView::setScrollbarsMode):
(WebCore::ScrollView::setFrameGeometry):
(WebCore::ScrollView::updateScrollbars):
* platform/mac/ScrollViewMac.mm:
(WebCore::ScrollView::platformContentsSize):
(WebCore::ScrollView::scrollBy):
* platform/mac/WidgetMac.mm:
(WebCore::Widget::convertFromContainingWindow):
(WebCore::Widget::convertToContainingWindow):
* platform/qt/ScrollViewQt.cpp:
(WebCore::ScrollView::ScrollViewPrivate::valueChanged):
(WebCore::ScrollView::resizeContents):
(WebCore::ScrollView::setFrameGeometry):
(WebCore::ScrollView::scrollOffset):
(WebCore::ScrollView::maximumScroll):
(WebCore::ScrollView::scrollBy):
(WebCore::ScrollView::setHScrollbarMode):
(WebCore::ScrollView::setVScrollbarMode):
(WebCore::ScrollView::setScrollbarsMode):
(WebCore::ScrollView::updateScrollbars):
* platform/win/ScrollViewWin.cpp:
(WebCore::ScrollView::ScrollViewPrivate::valueChanged):
(WebCore::ScrollView::ScrollViewPrivate::setAllowsScrolling):
(WebCore::ScrollView::resizeContents):
(WebCore::ScrollView::setFrameGeometry):
(WebCore::ScrollView::scrollOffset):
(WebCore::ScrollView::maximumScroll):
(WebCore::ScrollView::scrollBy):
(WebCore::ScrollView::setHScrollbarMode):
(WebCore::ScrollView::setVScrollbarMode):
(WebCore::ScrollView::setScrollbarsMode):
(WebCore::ScrollView::updateScrollbars):
* platform/wx/ScrollViewWx.cpp:
(WebCore::ScrollView::platformVisibleContentRect):
(WebCore::ScrollView::platformContentsSize):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::nodeAtPoint):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollRectToVisible):
(WebCore::RenderLayer::calculateClipRects):
(WebCore::RenderLayer::calculateRects):
* rendering/RenderView.cpp:
(WebCore::RenderView::absolutePosition):
(WebCore::RenderView::computeAbsoluteRepaintRect):
2008-09-25 David Smith <catfish.man@gmail.com>
Reviewed by Dave Hyatt.
......
......@@ -57,7 +57,7 @@ static int contentsX(AbstractView* abstractView)
FrameView* frameView = frame->view();
if (!frameView)
return 0;
return frameView->contentsX();
return frameView->scrollX();
}
static int contentsY(AbstractView* abstractView)
......@@ -70,7 +70,7 @@ static int contentsY(AbstractView* abstractView)
FrameView* frameView = frame->view();
if (!frameView)
return 0;
return frameView->contentsY();
return frameView->scrollY();
}
MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubble, bool cancelable, PassRefPtr<AbstractView> viewArg,
......
......@@ -246,7 +246,7 @@ int HTMLBodyElement::scrollLeft() const
Document* doc = document();
doc->updateLayoutIgnorePendingStylesheets();
FrameView* view = doc->view();
return view ? view->contentsX() : 0;
return view ? view->scrollX() : 0;
}
void HTMLBodyElement::setScrollLeft(int scrollLeft)
......@@ -255,7 +255,7 @@ void HTMLBodyElement::setScrollLeft(int scrollLeft)
if (sview) {
// Update the document's layout
document()->updateLayoutIgnorePendingStylesheets();
sview->setContentsPos(scrollLeft, sview->contentsY());
sview->setContentsPos(scrollLeft, sview->scrollY());
}
}
......@@ -265,7 +265,7 @@ int HTMLBodyElement::scrollTop() const
Document* doc = document();
doc->updateLayoutIgnorePendingStylesheets();
FrameView* view = doc->view();
return view ? view->contentsY() : 0;
return view ? view->scrollY() : 0;
}
void HTMLBodyElement::setScrollTop(int scrollTop)
......@@ -274,7 +274,7 @@ void HTMLBodyElement::setScrollTop(int scrollTop)
if (sview) {
// Update the document's layout
document()->updateLayoutIgnorePendingStylesheets();
sview->setContentsPos(sview->contentsX(), scrollTop);
sview->setContentsPos(sview->scrollX(), scrollTop);
}
}
......
......@@ -4133,7 +4133,7 @@ void FrameLoader::saveScrollPositionAndViewStateToItem(HistoryItem* item)
if (!item || !m_frame->view())
return;
item->setScrollPoint(IntPoint(m_frame->view()->contentsX(), m_frame->view()->contentsY()));
item->setScrollPoint(m_frame->view()->scrollPosition());
// FIXME: It would be great to work out a way to put this code in WebCore instead of calling through to the client.
m_client->saveViewStateToItem(item);
}
......
......@@ -618,7 +618,7 @@ int DOMWindow::scrollX() const
if (doc)
doc->updateLayoutIgnorePendingStylesheets();
return static_cast<int>(view->contentsX() / m_frame->pageZoomFactor());
return static_cast<int>(view->scrollX() / m_frame->pageZoomFactor());
}
int DOMWindow::scrollY() const
......@@ -635,7 +635,7 @@ int DOMWindow::scrollY() const
if (doc)
doc->updateLayoutIgnorePendingStylesheets();
return static_cast<int>(view->contentsY() / m_frame->pageZoomFactor());
return static_cast<int>(view->scrollY() / m_frame->pageZoomFactor());
}
bool DOMWindow::closed() const
......
......@@ -697,8 +697,8 @@ HitTestResult EventHandler::hitTestResultAtPoint(const IntPoint& point, bool all
if (!frame || !frame->contentRenderer())
break;
FrameView* view = static_cast<FrameView*>(widget);
IntPoint widgetPoint(result.localPoint().x() + view->contentsX() - n->renderer()->borderLeft() - n->renderer()->paddingLeft(),
result.localPoint().y() + view->contentsY() - n->renderer()->borderTop() - n->renderer()->paddingTop());
IntPoint widgetPoint(result.localPoint().x() + view->scrollX() - n->renderer()->borderLeft() - n->renderer()->paddingLeft(),
result.localPoint().y() + view->scrollY() - n->renderer()->borderTop() - n->renderer()->paddingTop());
HitTestResult widgetHitTestResult(widgetPoint);
frame->contentRenderer()->layer()->hitTest(HitTestRequest(true, true), widgetHitTestResult);
result = widgetHitTestResult;
......
......@@ -583,48 +583,48 @@ bool FrameView::scrollTo(const IntRect& bounds)
xe = x + curWidth - d->m_borderX;
// is xpos of target left of the view's border?
if (x < contentsX() + d->m_borderX)
deltax = x - contentsX() - d->m_borderX;
if (x < scrollX() + d->m_borderX)
deltax = x - scrollX() - d->m_borderX;
// is xpos of target right of the view's right border?
else if (xe + d->m_borderX > contentsX() + curWidth)
deltax = xe + d->m_borderX - (contentsX() + curWidth);
else if (xe + d->m_borderX > scrollX() + curWidth)
deltax = xe + d->m_borderX - (scrollX() + curWidth);
else
deltax = 0;
// is ypos of target above upper border?
if (y < contentsY() + d->m_borderY)
deltay = y - contentsY() - d->m_borderY;
if (y < scrollY() + d->m_borderY)
deltay = y - scrollY() - d->m_borderY;
// is ypos of target below lower border?
else if (ye + d->m_borderY > contentsY() + curHeight)
deltay = ye + d->m_borderY - (contentsY() + curHeight);
else if (ye + d->m_borderY > scrollY() + curHeight)
deltay = ye + d->m_borderY - (scrollY() + curHeight);
else
deltay = 0;
int maxx = curWidth - d->m_borderX;
int maxy = curHeight - d->m_borderY;
int scrollX = deltax > 0 ? (deltax > maxx ? maxx : deltax) : deltax == 0 ? 0 : (deltax > -maxx ? deltax : -maxx);
int scrollY = deltay > 0 ? (deltay > maxy ? maxy : deltay) : deltay == 0 ? 0 : (deltay > -maxy ? deltay : -maxy);
int newScrollX = deltax > 0 ? (deltax > maxx ? maxx : deltax) : deltax == 0 ? 0 : (deltax > -maxx ? deltax : -maxx);
int newScrollY = deltay > 0 ? (deltay > maxy ? maxy : deltay) : deltay == 0 ? 0 : (deltay > -maxy ? deltay : -maxy);
if (contentsX() + scrollX < 0)
scrollX = -contentsX();
else if (contentsWidth() - visibleWidth() - contentsX() < scrollX)
scrollX = contentsWidth() - visibleWidth() - contentsX();
if (scrollX() + newScrollX < 0)
newScrollX = -scrollX();
else if (contentsWidth() - visibleWidth() - scrollX() < newScrollX)
newScrollX = contentsWidth() - visibleWidth() - scrollX();
if (contentsY() + scrollY < 0)
scrollY = -contentsY();
else if (contentsHeight() - visibleHeight() - contentsY() < scrollY)
scrollY = contentsHeight() - visibleHeight() - contentsY();
if (scrollY() + newScrollY < 0)
newScrollY = -scrollY();
else if (contentsHeight() - visibleHeight() - scrollY() < newScrollY)
newScrollY = contentsHeight() - visibleHeight() - scrollY();
scrollBy(scrollX, scrollY);
scrollBy(newScrollX, newScrollY);
// generate abs(scroll.)
if (scrollX < 0)
scrollX = -scrollX;
if (scrollY < 0)
scrollY = -scrollY;
if (newScrollX < 0)
newScrollX = -newScrollX;
if (newScrollY < 0)
newScrollY = -newScrollY;
return scrollX != maxx && scrollY != maxy;
return newScrollX != maxx && newScrollY != maxy;
}
void FrameView::setMediaType(const String& mediaType)
......@@ -1054,13 +1054,7 @@ IntRect FrameView::windowClipRect(bool clipToContents) const
ASSERT(m_frame->view() == this);
// Set our clip rect to be our contents.
IntRect clipRect;
if (clipToContents)
clipRect = visibleContentRect();
else
clipRect = IntRect(contentsX(), contentsY(), width(), height());
clipRect = contentsToWindow(clipRect);
IntRect clipRect = contentsToWindow(visibleContentRect(!clipToContents));
if (!m_frame || !m_frame->document() || !m_frame->document()->ownerElement())
return clipRect;
......
......@@ -73,9 +73,16 @@ IntRect ScrollView::visibleContentRect(bool includeScrollbars) const
{
if (platformWidget())
return platformVisibleContentRect(includeScrollbars);
return IntRect(contentsX(), contentsY(),
max(0, width() - (verticalScrollbar() && includeScrollbars ? verticalScrollbar()->width() : 0)),
max(0, height() - (horizontalScrollbar() && includeScrollbars ? horizontalScrollbar()->height() : 0)));
return IntRect(IntPoint(m_scrollOffset.width(), m_scrollOffset.height()),
IntSize(max(0, width() - (verticalScrollbar() && includeScrollbars ? verticalScrollbar()->width() : 0)),
max(0, height() - (horizontalScrollbar() && includeScrollbars ? horizontalScrollbar()->height() : 0))));
}
IntSize ScrollView::contentsSize() const
{
if (platformWidget())
return platformContentsSize();
return m_contentsSize;
}
#if !PLATFORM(MAC)
......@@ -89,6 +96,11 @@ IntRect ScrollView::platformVisibleContentRect(bool) const
{
return IntRect();
}
IntSize ScrollView::platformContentsSize() const
{
return IntSize();
}
#endif
}
......
......@@ -48,6 +48,9 @@ typedef struct HRGN__* HRGN;
class wxScrollWinEvent;
#endif
// DANGER WILL ROBINSON! THIS FILE IS UNDERGOING HEAVY REFACTORING.
// Everything is changing!
// Port authors should wait until this refactoring is complete before attempting to implement this interface.
namespace WebCore {
class PlatformWheelEvent;
......@@ -68,15 +71,19 @@ namespace WebCore {
void setCanBlitOnScroll(bool);
bool canBlitOnScroll() const { return m_canBlitOnScroll; }
IntRect visibleContentRect(bool includeScrollbars = false) const;
int visibleWidth() const { return visibleContentRect().width(); }
int visibleHeight() const { return visibleContentRect().height(); }
IntRect visibleContentRect(bool includeScrollbars = false) const;
IntPoint scrollPosition() const { return visibleContentRect().location(); }
IntSize scrollOffset() const { return visibleContentRect().location() - IntPoint(); } // Gets the scrolled position as an IntSize. Convenient for adding to other sizes.
int scrollX() const { return scrollPosition().x(); }
int scrollY() const { return scrollPosition().y(); }
IntSize contentsSize() const;
int contentsWidth() const { return contentsSize().width(); }
int contentsHeight() const { return contentsSize().height(); }
int contentsWidth() const;
int contentsHeight() const;
int contentsX() const;
int contentsY() const;
IntSize scrollOffset() const;
void scrollBy(int dx, int dy);
virtual void scrollRectIntoViewRecursively(const IntRect&);
......@@ -153,14 +160,17 @@ namespace WebCore {
private:
HashSet<Widget*> m_children;
bool m_canBlitOnScroll;
IntSize m_scrollOffset; // FIXME: Would rather store this as a position, but we will wait to make this change until more code is shared.
IntSize m_contentsSize;
void init();
void platformAddChild(Widget*);
void platformRemoveChild(Widget*);
void platformSetCanBlitOnScroll();
IntRect platformVisibleContentRect(bool includeScrollbars) const;
IntSize platformContentsSize() const;
#if PLATFORM(MAC) && defined __OBJC__
public:
NSView* documentView() const;
......@@ -177,6 +187,8 @@ namespace WebCore {
class ScrollViewPrivate;
ScrollViewPrivate* m_data;
friend class ScrollViewPrivate; // FIXME: Temporary.
#if !PLATFORM(MAC) && !PLATFORM(WX)
public:
virtual void paint(GraphicsContext*, const IntRect&);
......
......@@ -110,8 +110,6 @@ public:
ScrollbarMode hScrollbarMode;
RefPtr<ScrollViewScrollbar> vBar;
RefPtr<ScrollViewScrollbar> hBar;
IntSize scrollOffset;
IntSize contentsSize;
IntSize viewPortSize;
bool inUpdateScrollbars;
HashSet<Widget*> children;
......@@ -208,16 +206,16 @@ void ScrollView::ScrollViewPrivate::adjustmentChanged(GtkAdjustment* adjustment,
ScrollViewPrivate* that = reinterpret_cast<ScrollViewPrivate*>(_that);
// Figure out if we really moved.
IntSize newOffset = that->scrollOffset;
IntSize newOffset = m_scrollOffset;
if (adjustment == that->horizontalAdjustment)
newOffset.setWidth(static_cast<int>(gtk_adjustment_get_value(adjustment)));
else if (adjustment == that->verticalAdjustment)
newOffset.setHeight(static_cast<int>(gtk_adjustment_get_value(adjustment)));
IntSize scrollDelta = newOffset - that->scrollOffset;
IntSize scrollDelta = newOffset - m_scrollOffset;
if (scrollDelta == IntSize())
return;
that->scrollOffset = newOffset;
m_scrollOffset = newOffset;
if (that->scrollbarsSuppressed)
return;
......@@ -302,7 +300,7 @@ void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj)
g_object_ref(m_data->verticalAdjustment);
}
updateScrollbars(m_data->scrollOffset);
updateScrollbars(m_scrollOffset);
}
void ScrollView::updateContents(const IntRect& updateRect, bool now)
......@@ -348,11 +346,11 @@ void ScrollView::setContentsPos(int newX, int newY)
void ScrollView::resizeContents(int w, int h)
{
IntSize newSize(w, h);
if (m_data->contentsSize == newSize)
if (m_contentsSize == newSize)
return;
m_data->contentsSize = newSize;
updateScrollbars(m_data->scrollOffset);
m_contentsSize = newSize;
updateScrollbars(m_scrollOffset);
}
int ScrollView::contentsX() const
......@@ -367,29 +365,29 @@ int ScrollView::contentsY() const
int ScrollView::contentsWidth() const
{
return m_data->contentsSize.width();
return m_contentsSize.width();
}
int ScrollView::contentsHeight() const
{
return m_data->contentsSize.height();
return m_contentsSize.height();
}
IntSize ScrollView::scrollOffset() const
{
return m_data->scrollOffset;
return m_scrollOffset;
}
IntSize ScrollView::maximumScroll() const
{
IntSize delta = (m_data->contentsSize - IntSize(visibleWidth(), visibleHeight())) - scrollOffset();
IntSize delta = (m_contentsSize - IntSize(visibleWidth(), visibleHeight())) - scrollOffset();
delta.clampNegativeToZero();
return delta;
}
void ScrollView::scrollBy(int dx, int dy)
{
IntSize scrollOffset = m_data->scrollOffset;
IntSize scrollOffset = m_scrollOffset;
IntSize newScrollOffset = scrollOffset + IntSize(dx, dy).shrunkTo(maximumScroll());
newScrollOffset.clampNegativeToZero();
......@@ -418,14 +416,14 @@ void ScrollView::suppressScrollbars(bool suppressed, bool repaintOnSuppress)
{
m_data->scrollbarsSuppressed = suppressed;
if (repaintOnSuppress)
updateScrollbars(m_data->scrollOffset);
updateScrollbars(m_scrollOffset);
}
void ScrollView::setHScrollbarMode(ScrollbarMode newMode)
{
if (m_data->hScrollbarMode != newMode) {
m_data->hScrollbarMode = newMode;
updateScrollbars(m_data->scrollOffset);
updateScrollbars(m_scrollOffset);
}
}
......@@ -433,14 +431,14 @@ void ScrollView::setVScrollbarMode(ScrollbarMode newMode)
{
if (m_data->vScrollbarMode != newMode) {
m_data->vScrollbarMode = newMode;
updateScrollbars(m_data->scrollOffset);
updateScrollbars(m_scrollOffset);
}
}
void ScrollView::setScrollbarsMode(ScrollbarMode newMode)
{
m_data->hScrollbarMode = m_data->vScrollbarMode = newMode;
updateScrollbars(m_data->scrollOffset);
updateScrollbars(m_scrollOffset);
}
void ScrollView::setFrameGeometry(const IntRect& newGeometry)
......@@ -452,7 +450,7 @@ void ScrollView::setFrameGeometry(const IntRect& newGeometry)
if (newGeometry == oldGeometry)
return;
if (newGeometry.width() != oldGeometry.width() || newGeometry.height() != oldGeometry.height()) {
updateScrollbars(m_data->scrollOffset);
updateScrollbars(m_scrollOffset);
static_cast<FrameView*>(this)->setNeedsLayout();
}
......@@ -570,7 +568,7 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset)
m_data->horizontalAdjustment->upper = contentsWidth();
gtk_adjustment_changed(m_data->horizontalAdjustment);
if (m_data->scrollOffset.width() != scroll.width()) {
if (m_scrollOffset.width() != scroll.width()) {
m_data->horizontalAdjustment->value = scroll.width();
gtk_adjustment_value_changed(m_data->horizontalAdjustment);
}
......@@ -605,7 +603,7 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset)
m_data->verticalAdjustment->upper = contentsHeight();
gtk_adjustment_changed(m_data->verticalAdjustment);
if (m_data->scrollOffset.height() != scroll.height()) {
if (m_scrollOffset.height() != scroll.height()) {
m_data->verticalAdjustment->value = scroll.height();
gtk_adjustment_value_changed(m_data->verticalAdjustment);
}
......@@ -639,9 +637,9 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset)
// This can happen when editing a body with overflow:hidden and scrolling to reveal selection.
// It can also happen when maximizing a window that has scrollbars (but the new maximized result
// does not).
IntSize scrollDelta = scroll - m_data->scrollOffset;
IntSize scrollDelta = scroll - m_scrollOffset;
if (scrollDelta != IntSize()) {
m_data->scrollOffset = scroll;
m_scrollOffset = scroll;
m_data->scrollBackingStore(scrollDelta);
}
......
......@@ -123,51 +123,18 @@ IntRect ScrollView::platformVisibleContentRect(bool includeScrollbars) const
return IntRect();
}
int ScrollView::contentsWidth() const
IntSize ScrollView::platformContentsSize() const
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
if (NSView* documentView = this->documentView())
return [documentView bounds].size.width;
END_BLOCK_OBJC_EXCEPTIONS;
return 0;
}
int ScrollView::contentsHeight() const
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
if (NSView* documentView = this->documentView())
return [documentView bounds].size.height;
END_BLOCK_OBJC_EXCEPTIONS;
return 0;
}
int ScrollView::contentsX() const
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
return [scrollView() documentVisibleRect].origin.x;
END_BLOCK_OBJC_EXCEPTIONS;
return 0;
}
int ScrollView::contentsY() const
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
return [scrollView() documentVisibleRect].origin.y;
END_BLOCK_OBJC_EXCEPTIONS;
return 0;
}
IntSize ScrollView::scrollOffset() const
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
return IntPoint([[scrollView() contentView] visibleRect].origin) - IntPoint();
return enclosingIntRect([documentView bounds]).size();
END_BLOCK_OBJC_EXCEPTIONS;
return IntSize();
}
void ScrollView::scrollBy(int dx, int dy)
{
setContentsPos(contentsX() + dx, contentsY() + dy);
setContentsPos(scrollX() + dx, scrollY() + dy);
}
void ScrollView::scrollRectIntoViewRecursively(const IntRect& r)
......
......@@ -304,7 +304,7 @@ IntPoint Widget::convertFromContainingWindow(const IntPoint& point) const
{
if (!platformWidget() && parent()) {
IntPoint result = parent()->convertFromContainingWindow(point);
result.move(parent()->contentsX() - x(), parent()->contentsY() - y());
result.move(parent()->scrollX() - x(), parent()->scrollY() - y());
return result;
}
......@@ -319,7 +319,7 @@ IntRect Widget::convertFromContainingWindow(const IntRect& rect) const
{
if (!platformWidget() && parent()) {
IntRect result = parent()->convertFromContainingWindow(rect);
result.move(parent()->contentsX() - x(), parent()->contentsY() - y());
result.move(parent()->scrollX() - x(), parent()->scrollY() - y());
return result;
}
......@@ -336,7 +336,7 @@ IntRect Widget::convertToContainingWindow(const IntRect& r) const
if (!parent())
return r;
IntRect result = r;
result.move(parent()->contentsX() - x(), parent()->contentsY() - y());
result.move(parent()->scrollX() - x(), parent()->scrollY() - y());
return parent()->convertToContainingWindow(result);
}
......@@ -353,7 +353,7 @@ IntPoint Widget::convertToContainingWindow(const IntPoint& p) const
if (!parent())
return p;
IntPoint result = p;
result.move(parent()->contentsX() - x(), parent()->contentsY() - y());
result.move(parent()->scrollX() - x(), parent()->scrollY() - y());