diff options
author | dglazkov@google.com <dglazkov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-30 18:48:28 +0000 |
---|---|---|
committer | dglazkov@google.com <dglazkov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-30 18:48:28 +0000 |
commit | 074ff16d3029256a9585529cad5487c1ae6eb409 (patch) | |
tree | e4d57cd79c533507a632ebf70c8ea8850113a9fc /webkit/port/platform/chromium/WidgetChromium.cpp | |
parent | 332ff119039b7dd3ba3d1994dde0b077f015bc03 (diff) | |
download | chromium_src-074ff16d3029256a9585529cad5487c1ae6eb409.zip chromium_src-074ff16d3029256a9585529cad5487c1ae6eb409.tar.gz chromium_src-074ff16d3029256a9585529cad5487c1ae6eb409.tar.bz2 |
Landing 36102:37604 merge on trunk
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4222 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port/platform/chromium/WidgetChromium.cpp')
-rw-r--r-- | webkit/port/platform/chromium/WidgetChromium.cpp | 190 |
1 files changed, 34 insertions, 156 deletions
diff --git a/webkit/port/platform/chromium/WidgetChromium.cpp b/webkit/port/platform/chromium/WidgetChromium.cpp index a36cb2c..9b84698 100644 --- a/webkit/port/platform/chromium/WidgetChromium.cpp +++ b/webkit/port/platform/chromium/WidgetChromium.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,93 +26,41 @@ #include "config.h" #include "Widget.h" -#include "Cursor.h" -#include "Document.h" -#include "Element.h" +#include "Assertions.h" +#include "ChromeClientChromium.h" #include "Frame.h" #include "FrameView.h" -#include "GraphicsContext.h" -#include "IntRect.h" -#include "WidgetClientChromium.h" +#include "Page.h" +#include "NotImplemented.h" namespace WebCore { -class WidgetPrivate +ChromeClientChromium* chromeClientChromium(Widget* widget) { -public: - WidgetClientChromium* client; - ScrollView* parent; - IntRect frameRect; - bool enabled; - bool suppressInvalidation; -}; - -Widget::Widget() - : data(new WidgetPrivate) -{ - data->client = 0; - data->parent = 0; - data->enabled = true; - data->suppressInvalidation = false; -} - -Widget::~Widget() -{ - if (parent()) - parent()->removeChild(this); - delete data; -} - -void Widget::setContainingWindow(PlatformWidget containingWindow) -{ - ASSERT_NOT_REACHED(); -} - -PlatformWidget Widget::containingWindow() const -{ - if (!data->client) - return NULL; - return data->client->containingWindow(); -} - -void Widget::setClient(WidgetClient* c) -{ - data->client = static_cast<WidgetClientChromium*>(c); -} - -WidgetClient* Widget::client() const -{ - return data->client; -} + FrameView* view; + if (widget->isFrameView()) { + view = static_cast<FrameView*>(widget); + } else if (widget->parent() && widget->parent()->isFrameView()) { + view = static_cast<FrameView*>(widget->parent()); + } else { + return 0; + } -IntRect Widget::frameGeometry() const -{ - return data->frameRect; -} + Page* page = view->frame() ? view->frame()->page() : 0; + if (!page) + return 0; -void Widget::setFrameGeometry(const IntRect &rect) -{ - data->frameRect = rect; + return static_cast<ChromeClientChromium*>(page->chrome()->client()); } -void Widget::setParent(ScrollView* v) +Widget::Widget(PlatformWidget widget) { - if (!v || !v->isAttachedToWindow()) - detachFromWindow(); - data->parent = v; - if (v && v->isAttachedToWindow()) - attachToWindow(); + init(widget); } -ScrollView* Widget::parent() const -{ - return data->parent; -} - -void Widget::removeFromParent() +Widget::~Widget() { - if (parent()) - parent()->removeChild(this); + ASSERT(!parent()); } void Widget::show() @@ -125,104 +73,34 @@ void Widget::hide() void Widget::setCursor(const Cursor& cursor) { - if (data->client) - data->client->setCursor(cursor); -} - -IntPoint Widget::convertToContainingWindow(const IntPoint& point) const -{ - IntPoint windowPoint = point; - for (const Widget *parentWidget = parent(), *childWidget = this; - parentWidget; - childWidget = parentWidget, parentWidget = parentWidget->parent()) - windowPoint = parentWidget->convertChildToSelf(childWidget, windowPoint); - return windowPoint; -} - -IntPoint Widget::convertFromContainingWindow(const IntPoint& point) const -{ - IntPoint widgetPoint = point; - for (const Widget *parentWidget = parent(), *childWidget = this; - parentWidget; - childWidget = parentWidget, parentWidget = parentWidget->parent()) - widgetPoint = parentWidget->convertSelfToChild(childWidget, widgetPoint); - return widgetPoint; -} - -IntRect Widget::convertToContainingWindow(const IntRect& rect) const -{ - IntRect convertedRect = rect; - convertedRect.setLocation(convertToContainingWindow(convertedRect.location())); - return convertedRect; -} - -IntPoint Widget::convertChildToSelf(const Widget* child, const IntPoint& point) const -{ - return IntPoint(point.x() + child->x(), point.y() + child->y()); -} - -IntPoint Widget::convertSelfToChild(const Widget* child, const IntPoint& point) const -{ - return IntPoint(point.x() - child->x(), point.y() - child->y()); + ChromeClientChromium* client = chromeClientChromium(this); + if (client) + client->setCursor(cursor); } void Widget::paint(GraphicsContext*, const IntRect&) { } -bool Widget::isEnabled() const -{ - return data->enabled; -} - -void Widget::setEnabled(bool e) -{ - if (e != data->enabled) { - data->enabled = e; - invalidate(); - } -} - -bool Widget::suppressInvalidation() const -{ - return data->suppressInvalidation; -} - -void Widget::setSuppressInvalidation(bool suppress) -{ - data->suppressInvalidation = suppress; -} - -void Widget::invalidate() +void Widget::setFocus() { - invalidateRect(IntRect(0, 0, width(), height())); + ChromeClientChromium* client = chromeClientChromium(this); + if (client) + client->focus(); } -void Widget::invalidateRect(const IntRect& r) +void Widget::setIsSelected(bool) { - if (data->suppressInvalidation) - return; - - if (!data->client) - return; - - IntRect windowRect = convertToContainingWindow(r); - - // Get our clip rect and intersect with it to ensure we don't invalidate too much. - IntRect clipRect = windowClipRect(); - windowRect.intersect(clipRect); - - data->client->invalidateRect(windowRect); } -void Widget::setFocus() +IntRect Widget::frameRect() const { - if (data->client) - data->client->setFocus(); + return m_frame; } -void Widget::setIsSelected(bool) +void Widget::setFrameRect(const IntRect& rect) { + m_frame = rect; } } // namespace WebCore |