Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: sky/engine/platform/Widget.cpp

Issue 691453002: Remove a lot of Widget APIs. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 16 matching lines...) Expand all
27 #include "config.h" 27 #include "config.h"
28 #include "platform/Widget.h" 28 #include "platform/Widget.h"
29 29
30 30
31 #include "wtf/Assertions.h" 31 #include "wtf/Assertions.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 Widget::Widget() 35 Widget::Widget()
36 : m_parent(0) 36 : m_parent(0)
37 , m_selfVisible(false)
38 , m_parentVisible(false)
39 { 37 {
40 } 38 }
41 39
42 Widget::~Widget() 40 Widget::~Widget()
43 { 41 {
44 ASSERT(!parent()); 42 ASSERT(!parent());
45 } 43 }
46 44
47 void Widget::setParent(Widget* widget)
48 {
49 ASSERT(!widget || !m_parent);
50 if (!widget || !widget->isVisible())
51 setParentVisible(false);
52 m_parent = widget;
53 if (widget && widget->isVisible())
54 setParentVisible(true);
55 }
56
57 Widget* Widget::root() const 45 Widget* Widget::root() const
58 { 46 {
59 const Widget* top = this; 47 const Widget* top = this;
60 while (top->parent()) 48 while (top->parent())
61 top = top->parent(); 49 top = top->parent();
62 if (top->isFrameView()) 50 if (top->isFrameView())
63 return const_cast<Widget*>(static_cast<const Widget*>(top)); 51 return const_cast<Widget*>(static_cast<const Widget*>(top));
64 return 0; 52 return 0;
65 } 53 }
66 54
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 108
121 IntPoint Widget::convertFromContainingWindow(const IntPoint& windowPoint) const 109 IntPoint Widget::convertFromContainingWindow(const IntPoint& windowPoint) const
122 { 110 {
123 if (const Widget* parentWidget = parent()) { 111 if (const Widget* parentWidget = parent()) {
124 IntPoint parentPoint = parentWidget->convertFromContainingWindow(windowP oint); 112 IntPoint parentPoint = parentWidget->convertFromContainingWindow(windowP oint);
125 return convertFromContainingView(parentPoint); 113 return convertFromContainingView(parentPoint);
126 } 114 }
127 return windowPoint; 115 return windowPoint;
128 } 116 }
129 117
118
130 FloatPoint Widget::convertFromContainingWindow(const FloatPoint& windowPoint) co nst 119 FloatPoint Widget::convertFromContainingWindow(const FloatPoint& windowPoint) co nst
131 { 120 {
132 // Widgets / windows are required to be IntPoint aligned, but we may need to convert 121 // Widgets / windows are required to be IntPoint aligned, but we may need to convert
133 // FloatPoint values within them (eg. for event co-ordinates). 122 // FloatPoint values within them (eg. for event co-ordinates).
134 IntPoint flooredPoint = flooredIntPoint(windowPoint); 123 IntPoint flooredPoint = flooredIntPoint(windowPoint);
135 FloatPoint parentPoint = this->convertFromContainingWindow(flooredPoint); 124 FloatPoint parentPoint = this->convertFromContainingWindow(flooredPoint);
136 FloatSize windowFraction = windowPoint - flooredPoint; 125 FloatSize windowFraction = windowPoint - flooredPoint;
137 // Use linear interpolation handle any fractional value (eg. for iframes sub ject to a transform 126 // Use linear interpolation handle any fractional value (eg. for iframes sub ject to a transform
138 // beyond just a simple translation). 127 // beyond just a simple translation).
139 // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs. 128 // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs.
(...skipping 10 matching lines...) Expand all
150 { 139 {
151 if (const Widget* parentWidget = parent()) { 140 if (const Widget* parentWidget = parent()) {
152 IntPoint parentPoint = convertToContainingView(localPoint); 141 IntPoint parentPoint = convertToContainingView(localPoint);
153 return parentWidget->convertToContainingWindow(parentPoint); 142 return parentWidget->convertToContainingWindow(parentPoint);
154 } 143 }
155 return localPoint; 144 return localPoint;
156 } 145 }
157 146
158 IntRect Widget::convertToContainingView(const IntRect& localRect) const 147 IntRect Widget::convertToContainingView(const IntRect& localRect) const
159 { 148 {
160 if (const Widget* parentWidget = parent()) {
161 IntRect parentRect(localRect);
162 parentRect.setLocation(parentWidget->convertChildToSelf(this, localRect. location()));
163 return parentRect;
164 }
165 return localRect; 149 return localRect;
166 } 150 }
167 151
168 IntRect Widget::convertFromContainingView(const IntRect& parentRect) const 152 IntRect Widget::convertFromContainingView(const IntRect& parentRect) const
169 { 153 {
170 if (const Widget* parentWidget = parent()) {
171 IntRect localRect = parentRect;
172 localRect.setLocation(parentWidget->convertSelfToChild(this, localRect.l ocation()));
173 return localRect;
174 }
175
176 return parentRect; 154 return parentRect;
177 } 155 }
178 156
179 IntPoint Widget::convertToContainingView(const IntPoint& localPoint) const 157 IntPoint Widget::convertToContainingView(const IntPoint& localPoint) const
180 { 158 {
181 if (const Widget* parentWidget = parent())
182 return parentWidget->convertChildToSelf(this, localPoint);
183
184 return localPoint; 159 return localPoint;
185 } 160 }
186 161
187 IntPoint Widget::convertFromContainingView(const IntPoint& parentPoint) const 162 IntPoint Widget::convertFromContainingView(const IntPoint& parentPoint) const
188 { 163 {
189 if (const Widget* parentWidget = parent())
190 return parentWidget->convertSelfToChild(this, parentPoint);
191
192 return parentPoint; 164 return parentPoint;
193 } 165 }
194 166
195 IntPoint Widget::convertChildToSelf(const Widget*, const IntPoint& point) const
196 {
197 return point;
198 }
199
200 IntPoint Widget::convertSelfToChild(const Widget*, const IntPoint& point) const
201 {
202 return point;
203 }
204
205 } // namespace blink 167 } // namespace blink
OLDNEW
« sky/engine/core/rendering/RenderObject.cpp ('K') | « sky/engine/platform/Widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698