Changeset 57521 in webkit


Ignore:
Timestamp:
Apr 13, 2010 10:20:44 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-13 Stephan Aßmus <superstippi@gmx.de>

Reviewed by David Levin.

[Haiku] Fix bridging Widget to native top-level BView.
https://bugs.webkit.org/show_bug.cgi?id=37419

In the Haiku port, there is no mapping between native widgets
and WebCore Widget instances. There is only a top-level BView
which renders a web page into a bitmap. For certain WebCore widget
functionality, we need to access this BView, like for setting the
current cursor or forcing focus. On the other hand, setting a
platform widget pointer on Widget results into completely different
behavior, like ScrollView tries to forward everything instead of
handling stuff itself. To make this work, the pointer to a "top-level"
BView is stored in every Widget for the Haiku port.

No new tests needed.

  • platform/Widget.h:
    • Added the m_topLevelPlatformWidget member for the Haiku platform.

(WebCore::Widget::setPlatformWidget):
(WebCore::Widget::topLevelPlatformWidget):
(WebCore::Widget::setTopLevelPlatformWidget):

  • platform/haiku/WidgetHaiku.cpp: (WebCore::AutoPlatformWidgetLocker::AutoPlatformWidgetLocker): (WebCore::AutoPlatformWidgetLocker::~AutoPlatformWidgetLocker): (WebCore::AutoPlatformWidgetLocker::isLocked):
    • helper class for locking the BView looper thread with a timeout

(WebCore::Widget::Widget):
(WebCore::Widget::setFocus):

  • Make sure the top-level view receives keyboard input.

(WebCore::Widget::setCursor):

  • Set the cursor on the top-level view.

(WebCore::Widget::show):
(WebCore::Widget::hide):

  • Don't show/hide the top-level view, but make the code correct for whenever we would map an individual BView per Widget.
  • Use setSelfVisible() and isParentVisible() like in other ports.
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r57520 r57521  
     12010-04-13  Stephan Aßmus  <superstippi@gmx.de>
     2
     3        Reviewed by David Levin.
     4
     5        [Haiku] Fix bridging Widget to native top-level BView.
     6        https://bugs.webkit.org/show_bug.cgi?id=37419
     7
     8        In the Haiku port, there is no mapping between native widgets
     9        and WebCore Widget instances. There is only a top-level BView
     10        which renders a web page into a bitmap. For certain WebCore widget
     11        functionality, we need to access this BView, like for setting the
     12        current cursor or forcing focus. On the other hand, setting a
     13        platform widget pointer on Widget results into completely different
     14        behavior, like ScrollView tries to forward everything instead of
     15        handling stuff itself. To make this work, the pointer to a "top-level"
     16        BView is stored in every Widget for the Haiku port.
     17
     18        No new tests needed.
     19
     20        * platform/Widget.h:
     21            - Added the m_topLevelPlatformWidget member for the Haiku platform.
     22        (WebCore::Widget::setPlatformWidget):
     23        (WebCore::Widget::topLevelPlatformWidget):
     24        (WebCore::Widget::setTopLevelPlatformWidget):
     25        * platform/haiku/WidgetHaiku.cpp:
     26        (WebCore::AutoPlatformWidgetLocker::AutoPlatformWidgetLocker):
     27        (WebCore::AutoPlatformWidgetLocker::~AutoPlatformWidgetLocker):
     28        (WebCore::AutoPlatformWidgetLocker::isLocked):
     29            - helper class for locking the BView looper thread with a timeout
     30        (WebCore::Widget::Widget):
     31        (WebCore::Widget::setFocus):
     32            - Make sure the top-level view receives keyboard input.
     33        (WebCore::Widget::setCursor):
     34            - Set the cursor on the top-level view.
     35        (WebCore::Widget::show):
     36        (WebCore::Widget::hide):
     37            - Don't show/hide the top-level view, but make the code correct
     38              for whenever we would map an individual BView per Widget.
     39            - Use setSelfVisible() and isParentVisible() like in other ports.
     40
    1412010-04-13  Jeremy Moskovich  <jeremy@chromium.org>
    242
  • trunk/WebCore/platform/Widget.h

    r55633 r57521  
    2222 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2323 * (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.
    2525 */
    2626
     
    118118    PlatformWidget platformWidget() const { return m_widget; }
    119119    void setPlatformWidget(PlatformWidget widget)
    120     { 
     120    {
    121121        if (widget != m_widget) {
    122122            releasePlatformWidget();
     
    125125        }
    126126    }
     127#if PLATFORM(HAIKU)
     128    PlatformWidget topLevelPlatformWidget() const { return m_topLevelPlatformWidget; }
     129    void setTopLevelPlatformWidget(PlatformWidget widget)
     130    {
     131        m_topLevelPlatformWidget = widget;
     132    }
     133#endif
    127134
    128135    int x() const { return frameRect().x(); }
     
    162169    virtual bool isFrameView() const { return false; }
    163170    virtual bool isPluginView() const { return false; }
    164     // FIXME: The Mac plug-in code should inherit from PluginView. When this happens PluginWidget and PluginView can become one class. 
     171    // FIXME: The Mac plug-in code should inherit from PluginView. When this happens PluginWidget and PluginView can become one class.
    165172    virtual bool isPluginWidget() const { return false; }
    166173    virtual bool isScrollbar() const { return false; }
     
    179186    IntRect convertToContainingWindow(const IntRect&) const;
    180187    IntRect convertFromContainingWindow(const IntRect&) const;
    181    
     188
    182189    IntPoint convertToContainingWindow(const IntPoint&) const;
    183190    IntPoint convertFromContainingWindow(const IntPoint&) const;
     
    190197#if PLATFORM(MAC)
    191198    NSView* getOuterView() const;
    192    
     199
    193200    static void beforeMouseDown(NSView*, Widget*);
    194201    static void afterMouseDown(NSView*, Widget*);
     
    208215    void releasePlatformWidget();
    209216    void retainPlatformWidget();
    210    
     217
    211218    // These methods are used to convert from the root widget to the containing window,
    212219    // which has behavior that may differ between platforms (e.g. Mac uses flipped window coordinates).
    213220    static IntRect convertFromRootToContainingWindow(const Widget* rootWidget, const IntRect&);
    214221    static IntRect convertFromContainingWindowToRoot(const Widget* rootWidget, const IntRect&);
    215    
     222
    216223    static IntPoint convertFromRootToContainingWindow(const Widget* rootWidget, const IntPoint&);
    217224    static IntPoint convertFromContainingWindowToRoot(const Widget* rootWidget, const IntPoint&);
     
    222229    bool m_selfVisible;
    223230    bool m_parentVisible;
    224    
     231
    225232    IntRect m_frame; // Not used when a native widget exists.
    226233
     
    228235    WidgetPrivate* m_data;
    229236#endif
     237#if PLATFORM(HAIKU)
     238    PlatformWidget m_topLevelPlatformWidget;
     239#endif
    230240};
    231241
  • trunk/WebCore/platform/haiku/WidgetHaiku.cpp

    r46923 r57521  
    11/*
    22 * Copyright (C) 2007 Ryan Leavengood <leavengood@gmail.com>
     3 * Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de>
    34 *
    45 * All rights reserved.
     
    3031
    3132#include "Cursor.h"
    32 #include "GraphicsContext.h"
    3333#include "IntRect.h"
    3434#include "NotImplemented.h"
    35 #include <Control.h>
    3635#include <View.h>
    37 
    3836
    3937namespace WebCore {
    4038
     39class AutoPlatformWidgetLocker {
     40public:
     41    AutoPlatformWidgetLocker(PlatformWidget widget)
     42        : m_widget(widget)
     43    {
     44        if (!m_widget || m_widget->LockLooperWithTimeout(5000) != B_OK)
     45            m_widget = 0;
     46    }
     47
     48    ~AutoPlatformWidgetLocker()
     49    {
     50        if (m_widget)
     51            m_widget->UnlockLooper();
     52    }
     53
     54    bool isLocked() const
     55    {
     56        return m_widget;
     57    }
     58
     59private:
     60    PlatformWidget m_widget;
     61};
     62
    4163Widget::Widget(PlatformWidget widget)
     64    : m_topLevelPlatformWidget(0)
    4265{
    4366    init(widget);
     
    6083void Widget::setFocus()
    6184{
    62     if (platformWidget())
    63         platformWidget()->MakeFocus();
     85    AutoPlatformWidgetLocker locker(topLevelPlatformWidget());
     86    if (locker.isLocked())
     87        topLevelPlatformWidget()->MakeFocus();
    6488}
    6589
    6690void Widget::setCursor(const Cursor& cursor)
    6791{
    68     if (platformWidget())
    69         platformWidget()->SetViewCursor(cursor.impl());
     92    AutoPlatformWidgetLocker locker(topLevelPlatformWidget());
     93    if (locker.isLocked())
     94        topLevelPlatformWidget()->SetViewCursor(cursor.impl());
    7095}
    7196
    7297void Widget::show()
    7398{
    74     if (platformWidget())
     99    setSelfVisible(true);
     100    if (!isParentVisible())
     101        return;
     102
     103    AutoPlatformWidgetLocker locker(platformWidget());
     104    if (locker.isLocked() && platformWidget()->IsHidden())
    75105        platformWidget()->Show();
    76106}
     
    78108void Widget::hide()
    79109{
    80     if (platformWidget())
     110    setSelfVisible(false);
     111    if (!isParentVisible())
     112        return;
     113
     114    AutoPlatformWidgetLocker locker(platformWidget());
     115    if (locker.isLocked() && !platformWidget()->IsHidden())
    81116        platformWidget()->Hide();
    82117}
    83118
    84 void Widget::paint(GraphicsContext* p, IntRect const& r)
     119void Widget::paint(GraphicsContext*, IntRect const&)
    85120{
    86121    notImplemented();
Note: See TracChangeset for help on using the changeset viewer.