1 /*
2 * Copyright 2007, The Android Open Source Project
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #include "config.h"
27 #include "Widget.h"
28
29 #include "Font.h"
30 #include "FrameView.h"
31 #include "GraphicsContext.h"
32 #include "NotImplemented.h"
33 #include "WebCoreFrameBridge.h"
34 #include "WebCoreViewBridge.h"
35 #include "WebViewCore.h"
36
37 namespace WebCore {
38
Widget(PlatformWidget widget)39 Widget::Widget(PlatformWidget widget)
40 {
41 init(widget);
42 }
43
~Widget()44 Widget::~Widget()
45 {
46 ASSERT(!parent());
47 releasePlatformWidget();
48 }
49
frameRect() const50 IntRect Widget::frameRect() const
51 {
52 if (!platformWidget())
53 return m_frame;
54 return platformWidget()->getBounds();
55 }
56
setFocus(bool focused)57 void Widget::setFocus(bool focused)
58 {
59 notImplemented();
60 }
61
paint(GraphicsContext * ctx,const IntRect & r)62 void Widget::paint(GraphicsContext* ctx, const IntRect& r)
63 {
64 }
65
releasePlatformWidget()66 void Widget::releasePlatformWidget()
67 {
68 Release(platformWidget());
69 }
70
retainPlatformWidget()71 void Widget::retainPlatformWidget()
72 {
73 Retain(platformWidget());
74 }
75
setCursor(const Cursor & cursor)76 void Widget::setCursor(const Cursor& cursor)
77 {
78 notImplemented();
79 }
80
show()81 void Widget::show()
82 {
83 notImplemented();
84 }
85
hide()86 void Widget::hide()
87 {
88 notImplemented();
89 }
90
setFrameRect(const IntRect & rect)91 void Widget::setFrameRect(const IntRect& rect)
92 {
93 m_frame = rect;
94 // platformWidget() is 0 when called from Scrollbar
95 if (!platformWidget())
96 return;
97 platformWidget()->setLocation(rect.x(), rect.y());
98 platformWidget()->setSize(rect.width(), rect.height());
99 }
100
setIsSelected(bool isSelected)101 void Widget::setIsSelected(bool isSelected)
102 {
103 notImplemented();
104 }
105
textWrapWidth() const106 int Widget::textWrapWidth() const
107 {
108 const Widget* widget = this;
109 while (!widget->isFrameView()) {
110 widget = widget->parent();
111 if (!widget)
112 break;
113 }
114 if (!widget)
115 return 0;
116 android::WebViewCore* core = android::WebViewCore::getWebViewCore(
117 static_cast<const ScrollView*>(widget));
118 if (!core)
119 return 0;
120 return core->textWrapWidth();
121 }
122
123 } // WebCore namepsace
124