mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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
This commit is contained in:
parent
83f05ff8bf
commit
ca6775b3da
@ -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;
|
||||
|
||||
@ -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> frameView;
|
||||
@ -321,8 +318,6 @@ void LocalFrame::createView(const IntSize& viewportSize, const Color& background
|
||||
setView(frameView);
|
||||
|
||||
frameView->updateBackgroundRecursively(backgroundColor, transparent);
|
||||
|
||||
frameView->setParentVisible(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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<Widget> {
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user