From ca6775b3da0cb5d0def96dd98e1e7218256872ec Mon Sep 17 00:00:00 2001 From: Elliott Sprehn Date: Wed, 29 Oct 2014 15:23:10 -0700 Subject: [PATCH] Remove a lot of Widget APIs. We don't need a lot of the Widget API. I also removed the visibility code which seems to have been broken when we removed FrameView::show and hide(), which looks like it would have broken image loading. Unfortuantely we don't have pixel tests or tests that load images so I can't test this yet. Even so it's a good simplificatin since our system has no concept of hidden widgets. R=abarth@chromium.org, ojan@chromium.org Review URL: https://codereview.chromium.org/691453002 --- engine/core/frame/FrameView.h | 7 ++--- engine/core/frame/LocalFrame.cpp | 5 ---- engine/core/rendering/RenderObject.cpp | 8 ++---- engine/platform/Widget.cpp | 40 +------------------------- engine/platform/Widget.h | 26 ++--------------- 5 files changed, 8 insertions(+), 78 deletions(-) diff --git a/engine/core/frame/FrameView.h b/engine/core/frame/FrameView.h index 92c33e0de..efd840c74 100644 --- a/engine/core/frame/FrameView.h +++ b/engine/core/frame/FrameView.h @@ -63,10 +63,9 @@ public: virtual ~FrameView(); - HostWindow* hostWindow() const; - - void invalidateRect(const IntRect&); - void setFrameRect(const IntRect&); + virtual HostWindow* hostWindow() const override; + virtual void invalidateRect(const IntRect&) override; + virtual void setFrameRect(const IntRect&) override; LocalFrame& frame() const { return *m_frame; } Page* page() const; diff --git a/engine/core/frame/LocalFrame.cpp b/engine/core/frame/LocalFrame.cpp index 64b11aa2b..c102ae36e 100644 --- a/engine/core/frame/LocalFrame.cpp +++ b/engine/core/frame/LocalFrame.cpp @@ -307,9 +307,6 @@ void LocalFrame::createView(const IntSize& viewportSize, const Color& background ASSERT(this); ASSERT(page()); - if (view()) - view()->setParentVisible(false); - setView(nullptr); RefPtr frameView; @@ -321,8 +318,6 @@ void LocalFrame::createView(const IntSize& viewportSize, const Color& background setView(frameView); frameView->updateBackgroundRecursively(backgroundColor, transparent); - - frameView->setParentVisible(true); } diff --git a/engine/core/rendering/RenderObject.cpp b/engine/core/rendering/RenderObject.cpp index 5b8ae7bfc..3c3b12671 100644 --- a/engine/core/rendering/RenderObject.cpp +++ b/engine/core/rendering/RenderObject.cpp @@ -2567,13 +2567,9 @@ void RenderObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio bool RenderObject::willRenderImage(ImageResource*) { + // FIXME(sky): Do we want to keep this? // We will not render a new image when Active DOM is suspended - if (document().activeDOMObjectsAreSuspended()) - return false; - - // If we're not in a window (i.e., we're dormant from being in a background tab) - // then we don't want to render either. - return document().view()->isVisible(); + return !document().activeDOMObjectsAreSuspended(); } int RenderObject::caretMinOffset() const diff --git a/engine/platform/Widget.cpp b/engine/platform/Widget.cpp index 40683290a..e275cf7af 100644 --- a/engine/platform/Widget.cpp +++ b/engine/platform/Widget.cpp @@ -34,8 +34,6 @@ namespace blink { Widget::Widget() : m_parent(0) - , m_selfVisible(false) - , m_parentVisible(false) { } @@ -44,16 +42,6 @@ Widget::~Widget() ASSERT(!parent()); } -void Widget::setParent(Widget* widget) -{ - ASSERT(!widget || !m_parent); - if (!widget || !widget->isVisible()) - setParentVisible(false); - m_parent = widget; - if (widget && widget->isVisible()) - setParentVisible(true); -} - Widget* Widget::root() const { const Widget* top = this; @@ -127,6 +115,7 @@ IntPoint Widget::convertFromContainingWindow(const IntPoint& windowPoint) const return windowPoint; } + FloatPoint Widget::convertFromContainingWindow(const FloatPoint& windowPoint) const { // Widgets / windows are required to be IntPoint aligned, but we may need to convert @@ -157,49 +146,22 @@ IntPoint Widget::convertToContainingWindow(const IntPoint& localPoint) const IntRect Widget::convertToContainingView(const IntRect& localRect) const { - if (const Widget* parentWidget = parent()) { - IntRect parentRect(localRect); - parentRect.setLocation(parentWidget->convertChildToSelf(this, localRect.location())); - return parentRect; - } return localRect; } IntRect Widget::convertFromContainingView(const IntRect& parentRect) const { - if (const Widget* parentWidget = parent()) { - IntRect localRect = parentRect; - localRect.setLocation(parentWidget->convertSelfToChild(this, localRect.location())); - return localRect; - } - return parentRect; } IntPoint Widget::convertToContainingView(const IntPoint& localPoint) const { - if (const Widget* parentWidget = parent()) - return parentWidget->convertChildToSelf(this, localPoint); - return localPoint; } IntPoint Widget::convertFromContainingView(const IntPoint& parentPoint) const { - if (const Widget* parentWidget = parent()) - return parentWidget->convertSelfToChild(this, parentPoint); - return parentPoint; } -IntPoint Widget::convertChildToSelf(const Widget*, const IntPoint& point) const -{ - return point; -} - -IntPoint Widget::convertSelfToChild(const Widget*, const IntPoint& point) const -{ - return point; -} - } // namespace blink diff --git a/engine/platform/Widget.h b/engine/platform/Widget.h index 4e6600ae9..b5b33c9e9 100644 --- a/engine/platform/Widget.h +++ b/engine/platform/Widget.h @@ -40,14 +40,7 @@ class Event; class GraphicsContext; class HostWindow; -// The Widget class serves as a base class for three kinds of objects: -// (1) Scrollable areas (ScrollView) -// (2) Scrollbars (Scrollbar) -// (3) Plugins (PluginView) -// -// Widgets are connected in a hierarchy, with the restriction that plugins and -// scrollbars are always leaves of the tree. Only ScrollViews can have children -// (and therefore the Widget class has no concept of children). +// The Widget class serves as a base class for Scrollbar and FrameView. class PLATFORM_EXPORT Widget : public RefCounted { public: Widget(); @@ -73,23 +66,14 @@ public: void invalidate() { invalidateRect(boundsRect()); } virtual void invalidateRect(const IntRect&) = 0; - bool isSelfVisible() const { return m_selfVisible; } // Whether or not we have been explicitly marked as visible or not. - bool isParentVisible() const { return m_parentVisible; } // Whether or not our parent is visible. - bool isVisible() const { return m_selfVisible && m_parentVisible; } // Whether or not we are actually visible. - virtual void setParentVisible(bool visible) { m_parentVisible = visible; } - void setSelfVisible(bool v) { m_selfVisible = v; } - virtual bool isFrameView() const { return false; } virtual bool isScrollbar() const { return false; } - virtual bool isScrollView() const { return false; } virtual HostWindow* hostWindow() const { ASSERT_NOT_REACHED(); return 0; } - virtual void setParent(Widget*); + void setParent(Widget* parent) { m_parent = parent; } Widget* parent() const { return m_parent; } Widget* root() const; - virtual void handleEvent(Event*) { } - IntRect convertToRootView(const IntRect&) const; IntRect convertFromRootView(const IntRect&) const; @@ -113,15 +97,9 @@ public: virtual IntPoint convertToContainingView(const IntPoint&) const; virtual IntPoint convertFromContainingView(const IntPoint&) const; - // Virtual methods to convert points to/from child widgets - virtual IntPoint convertChildToSelf(const Widget*, const IntPoint&) const; - virtual IntPoint convertSelfToChild(const Widget*, const IntPoint&) const; - private: Widget* m_parent; IntRect m_frame; - bool m_selfVisible; - bool m_parentVisible; }; } // namespace blink -- GitLab