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

Side by Side Diff: third_party/WebKit/Source/platform/FrameViewBase.cpp

Issue 2722953003: Part 1 to rename platform/Widget to platform/FrameViewBase. (Closed)
Patch Set: Created 3 years, 9 months 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
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "platform/Widget.h" 27 #include "platform/FrameViewBase.h"
28 28
29 #include "wtf/Assertions.h" 29 #include "wtf/Assertions.h"
30 30
31 namespace blink { 31 namespace blink {
32 32
33 Widget::Widget() 33 FrameViewBase::FrameViewBase()
34 : m_parent(nullptr), m_selfVisible(false), m_parentVisible(false) {} 34 : m_parent(nullptr), m_selfVisible(false), m_parentVisible(false) {}
35 35
36 Widget::~Widget() {} 36 FrameViewBase::~FrameViewBase() {}
37 37
38 DEFINE_TRACE(Widget) { 38 DEFINE_TRACE(FrameViewBase) {
39 visitor->trace(m_parent); 39 visitor->trace(m_parent);
40 } 40 }
41 41
42 void Widget::setParent(Widget* widget) { 42 void FrameViewBase::setParent(FrameViewBase* frameViewBase) {
43 ASSERT(!widget || !m_parent); 43 DCHECK(!frameViewBase || !m_parent);
44 if (!widget || !widget->isVisible()) 44 if (!frameViewBase || !frameViewBase->isVisible())
45 setParentVisible(false); 45 setParentVisible(false);
46 m_parent = widget; 46 m_parent = frameViewBase;
47 if (widget && widget->isVisible()) 47 if (frameViewBase && frameViewBase->isVisible())
48 setParentVisible(true); 48 setParentVisible(true);
49 } 49 }
50 50
51 Widget* Widget::root() const { 51 FrameViewBase* FrameViewBase::root() const {
52 const Widget* top = this; 52 const FrameViewBase* top = this;
53 while (top->parent()) 53 while (top->parent())
54 top = top->parent(); 54 top = top->parent();
55 if (top->isFrameView()) 55 if (top->isFrameView())
56 return const_cast<Widget*>(static_cast<const Widget*>(top)); 56 return const_cast<FrameViewBase*>(static_cast<const FrameViewBase*>(top));
57 return 0; 57 return 0;
58 } 58 }
59 59
60 IntRect Widget::convertFromRootFrame(const IntRect& rectInRootFrame) const { 60 IntRect FrameViewBase::convertFromRootFrame(const IntRect& rectInRootFrame) cons t {
61 if (const Widget* parentWidget = parent()) { 61 if (const FrameViewBase* parentFrameViewBase = parent()) {
62 IntRect parentRect = parentWidget->convertFromRootFrame(rectInRootFrame); 62 IntRect parentRect = parentFrameViewBase->convertFromRootFrame(rectInRootFra me);
63 return convertFromContainingWidget(parentRect); 63 return convertFromContainingWidget(parentRect);
64 } 64 }
65 return rectInRootFrame; 65 return rectInRootFrame;
66 } 66 }
67 67
68 IntRect Widget::convertToRootFrame(const IntRect& localRect) const { 68 IntRect FrameViewBase::convertToRootFrame(const IntRect& localRect) const {
69 if (const Widget* parentWidget = parent()) { 69 if (const FrameViewBase* parentFrameViewBase = parent()) {
70 IntRect parentRect = convertToContainingWidget(localRect); 70 IntRect parentRect = convertToContainingWidget(localRect);
71 return parentWidget->convertToRootFrame(parentRect); 71 return parentFrameViewBase->convertToRootFrame(parentRect);
72 } 72 }
73 return localRect; 73 return localRect;
74 } 74 }
75 75
76 IntPoint Widget::convertFromRootFrame(const IntPoint& pointInRootFrame) const { 76 IntPoint FrameViewBase::convertFromRootFrame(const IntPoint& pointInRootFrame) c onst {
77 if (const Widget* parentWidget = parent()) { 77 if (const FrameViewBase* parentFrameViewBase = parent()) {
78 IntPoint parentPoint = parentWidget->convertFromRootFrame(pointInRootFrame); 78 IntPoint parentPoint = parentFrameViewBase->convertFromRootFrame(pointInRoot Frame);
79 return convertFromContainingWidget(parentPoint); 79 return convertFromContainingWidget(parentPoint);
80 } 80 }
81 return pointInRootFrame; 81 return pointInRootFrame;
82 } 82 }
83 83
84 FloatPoint Widget::convertFromRootFrame( 84 FloatPoint FrameViewBase::convertFromRootFrame(
85 const FloatPoint& pointInRootFrame) const { 85 const FloatPoint& pointInRootFrame) const {
86 // Widgets / windows are required to be IntPoint aligned, but we may need to 86 // FrameViewBase / windows are required to be IntPoint aligned, but we may nee d to
87 // convert FloatPoint values within them (eg. for event co-ordinates). 87 // convert FloatPoint values within them (eg. for event co-ordinates).
88 IntPoint flooredPoint = flooredIntPoint(pointInRootFrame); 88 IntPoint flooredPoint = flooredIntPoint(pointInRootFrame);
89 FloatPoint parentPoint = this->convertFromRootFrame(flooredPoint); 89 FloatPoint parentPoint = this->convertFromRootFrame(flooredPoint);
90 FloatSize windowFraction = pointInRootFrame - flooredPoint; 90 FloatSize windowFraction = pointInRootFrame - flooredPoint;
91 // Use linear interpolation handle any fractional value (eg. for iframes 91 // Use linear interpolation handle any fractional value (eg. for iframes
92 // subject to a transform beyond just a simple translation). 92 // subject to a transform beyond just a simple translation).
93 // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs. 93 // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs.
94 if (!windowFraction.isEmpty()) { 94 if (!windowFraction.isEmpty()) {
95 const int kFactor = 1000; 95 const int kFactor = 1000;
96 IntPoint parentLineEnd = this->convertFromRootFrame( 96 IntPoint parentLineEnd = this->convertFromRootFrame(
97 flooredPoint + roundedIntSize(windowFraction.scaledBy(kFactor))); 97 flooredPoint + roundedIntSize(windowFraction.scaledBy(kFactor)));
98 FloatSize parentFraction = 98 FloatSize parentFraction =
99 (parentLineEnd - parentPoint).scaledBy(1.0f / kFactor); 99 (parentLineEnd - parentPoint).scaledBy(1.0f / kFactor);
100 parentPoint.move(parentFraction); 100 parentPoint.move(parentFraction);
101 } 101 }
102 return parentPoint; 102 return parentPoint;
103 } 103 }
104 104
105 IntPoint Widget::convertToRootFrame(const IntPoint& localPoint) const { 105 IntPoint FrameViewBase::convertToRootFrame(const IntPoint& localPoint) const {
106 if (const Widget* parentWidget = parent()) { 106 if (const FrameViewBase* parentFrameViewBase = parent()) {
107 IntPoint parentPoint = convertToContainingWidget(localPoint); 107 IntPoint parentPoint = convertToContainingWidget(localPoint);
108 return parentWidget->convertToRootFrame(parentPoint); 108 return parentFrameViewBase->convertToRootFrame(parentPoint);
109 } 109 }
110 return localPoint; 110 return localPoint;
111 } 111 }
112 112
113 IntRect Widget::convertToContainingWidget(const IntRect& localRect) const { 113 IntRect FrameViewBase::convertToContainingWidget(const IntRect& localRect) const {
114 if (const Widget* parentWidget = parent()) { 114 if (const FrameViewBase* parentFrameViewBase = parent()) {
115 IntRect parentRect(localRect); 115 IntRect parentRect(localRect);
116 parentRect.setLocation( 116 parentRect.setLocation(
117 parentWidget->convertChildToSelf(this, localRect.location())); 117 parentFrameViewBase->convertChildToSelf(this, localRect.location()));
118 return parentRect; 118 return parentRect;
119 } 119 }
120 return localRect; 120 return localRect;
121 } 121 }
122 122
123 IntRect Widget::convertFromContainingWidget(const IntRect& parentRect) const { 123 IntRect FrameViewBase::convertFromContainingWidget(const IntRect& parentRect) co nst {
124 if (const Widget* parentWidget = parent()) { 124 if (const FrameViewBase* parentFrameViewBase = parent()) {
125 IntRect localRect = parentRect; 125 IntRect localRect = parentRect;
126 localRect.setLocation( 126 localRect.setLocation(
127 parentWidget->convertSelfToChild(this, localRect.location())); 127 parentFrameViewBase->convertSelfToChild(this, localRect.location()));
128 return localRect; 128 return localRect;
129 } 129 }
130 130
131 return parentRect; 131 return parentRect;
132 } 132 }
133 133
134 IntPoint Widget::convertToContainingWidget(const IntPoint& localPoint) const { 134 IntPoint FrameViewBase::convertToContainingWidget(const IntPoint& localPoint) co nst {
135 if (const Widget* parentWidget = parent()) 135 if (const FrameViewBase* parentFrameViewBase = parent())
136 return parentWidget->convertChildToSelf(this, localPoint); 136 return parentFrameViewBase->convertChildToSelf(this, localPoint);
137 137
138 return localPoint; 138 return localPoint;
139 } 139 }
140 140
141 IntPoint Widget::convertFromContainingWidget( 141 IntPoint FrameViewBase::convertFromContainingWidget(
142 const IntPoint& parentPoint) const { 142 const IntPoint& parentPoint) const {
143 if (const Widget* parentWidget = parent()) 143 if (const FrameViewBase* parentFrameViewBase = parent())
144 return parentWidget->convertSelfToChild(this, parentPoint); 144 return parentFrameViewBase->convertSelfToChild(this, parentPoint);
145 145
146 return parentPoint; 146 return parentPoint;
147 } 147 }
148 148
149 IntPoint Widget::convertChildToSelf(const Widget*, 149 IntPoint FrameViewBase::convertChildToSelf(const FrameViewBase*,
150 const IntPoint& point) const { 150 const IntPoint& point) const {
151 return point; 151 return point;
152 } 152 }
153 153
154 IntPoint Widget::convertSelfToChild(const Widget*, 154 IntPoint FrameViewBase::convertSelfToChild(const FrameViewBase*,
155 const IntPoint& point) const { 155 const IntPoint& point) const {
156 return point; 156 return point;
157 } 157 }
158 158
159 } // namespace blink 159 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/FrameViewBase.h ('k') | third_party/WebKit/Source/platform/HostWindow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698