diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/platform/Widget.cpp')
-rw-r--r-- | src/3rdparty/webkit/WebCore/platform/Widget.cpp | 106 |
1 files changed, 81 insertions, 25 deletions
diff --git a/src/3rdparty/webkit/WebCore/platform/Widget.cpp b/src/3rdparty/webkit/WebCore/platform/Widget.cpp index a456431b09..5bb903b516 100644 --- a/src/3rdparty/webkit/WebCore/platform/Widget.cpp +++ b/src/3rdparty/webkit/WebCore/platform/Widget.cpp @@ -69,42 +69,61 @@ void Widget::removeFromParent() parent()->removeChild(this); } -#if !PLATFORM(MAC) +IntRect Widget::convertFromContainingWindow(const IntRect& windowRect) const +{ + if (const ScrollView* parentScrollView = parent()) { + IntRect parentRect = parentScrollView->convertFromContainingWindow(windowRect); + return convertFromContainingView(parentRect); + } + return convertFromContainingWindowToRoot(this, windowRect); +} + +IntRect Widget::convertToContainingWindow(const IntRect& localRect) const +{ + if (const ScrollView* parentScrollView = parent()) { + IntRect parentRect = convertToContainingView(localRect); + return parentScrollView->convertToContainingWindow(parentRect); + } + return convertFromRootToContainingWindow(this, localRect); +} + +IntPoint Widget::convertFromContainingWindow(const IntPoint& windowPoint) const +{ + if (const ScrollView* parentScrollView = parent()) { + IntPoint parentPoint = parentScrollView->convertFromContainingWindow(windowPoint); + return convertFromContainingView(parentPoint); + } + return convertFromContainingWindowToRoot(this, windowPoint); +} -IntRect Widget::convertToContainingWindow(const IntRect& rect) const +IntPoint Widget::convertToContainingWindow(const IntPoint& localPoint) const { - IntRect convertedRect = rect; - convertedRect.setLocation(convertToContainingWindow(convertedRect.location())); - return convertedRect; + if (const ScrollView* parentScrollView = parent()) { + IntPoint parentPoint = convertToContainingView(localPoint); + return parentScrollView->convertToContainingWindow(parentPoint); + } + return convertFromRootToContainingWindow(this, localPoint); } -IntPoint Widget::convertToContainingWindow(const IntPoint& point) const +#if !PLATFORM(MAC) +IntRect Widget::convertFromRootToContainingWindow(const Widget*, const IntRect& rect) { - IntPoint windowPoint = point; - const Widget* childWidget = this; - for (const ScrollView* parentScrollView = parent(); - parentScrollView; - childWidget = parentScrollView, parentScrollView = parentScrollView->parent()) - windowPoint = parentScrollView->convertChildToSelf(childWidget, windowPoint); - return windowPoint; + return rect; } -IntPoint Widget::convertFromContainingWindow(const IntPoint& point) const +IntRect Widget::convertFromContainingWindowToRoot(const Widget*, const IntRect& rect) { - IntPoint widgetPoint = point; - const Widget* childWidget = this; - for (const ScrollView* parentScrollView = parent(); - parentScrollView; - childWidget = parentScrollView, parentScrollView = parentScrollView->parent()) - widgetPoint = parentScrollView->convertSelfToChild(childWidget, widgetPoint); - return widgetPoint; + return rect; } -IntRect Widget::convertFromContainingWindow(const IntRect& rect) const +IntPoint Widget::convertFromRootToContainingWindow(const Widget*, const IntPoint& point) { - IntRect result = rect; - result.setLocation(convertFromContainingWindow(rect.location())); - return result; + return point; +} + +IntPoint Widget::convertFromContainingWindowToRoot(const Widget*, const IntPoint& point) +{ + return point; } #endif @@ -118,4 +137,41 @@ void Widget::retainPlatformWidget() } #endif +IntRect Widget::convertToContainingView(const IntRect& localRect) const +{ + if (const ScrollView* parentScrollView = parent()) { + IntRect parentRect(localRect); + parentRect.setLocation(parentScrollView->convertChildToSelf(this, localRect.location())); + return parentRect; + } + return localRect; } + +IntRect Widget::convertFromContainingView(const IntRect& parentRect) const +{ + if (const ScrollView* parentScrollView = parent()) { + IntRect localRect = parentRect; + localRect.setLocation(parentScrollView->convertSelfToChild(this, localRect.location())); + return localRect; + } + + return parentRect; +} + +IntPoint Widget::convertToContainingView(const IntPoint& localPoint) const +{ + if (const ScrollView* parentScrollView = parent()) + return parentScrollView->convertChildToSelf(this, localPoint); + + return localPoint; +} + +IntPoint Widget::convertFromContainingView(const IntPoint& parentPoint) const +{ + if (const ScrollView* parentScrollView = parent()) + return parentScrollView->convertSelfToChild(this, parentPoint); + + return parentPoint; +} + +} // namespace WebCore |