[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/unity/WebKit/WebCore/platform/qt
From:       Nikolas Zimmermann <wildfox () kde ! org>
Date:       2006-07-31 21:19:05
Message-ID: 1154380745.676194.18209.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 568343 by wildfox:

Lazy create the widget, saves one creation/destruction for ie. line edits.
Also avoids the top level windows created for apple.com rendering.


 M  +70 -50    WidgetQt.cpp  


--- branches/work/unity/WebKit/WebCore/platform/qt/WidgetQt.cpp #568342:568343
@@ -30,6 +30,7 @@
 #include "Widget.h"
 
 #include "Cursor.h"
+#include "HelperQt.h"
 #include "Font.h"
 #include "GraphicsContext.h"
 #include "IntRect.h"
@@ -38,14 +39,11 @@
 #include <QDebug>
 #include <QWidget>
 
-#define notImplemented() do { fprintf(stderr, "FIXME: UNIMPLEMENTED: %s:%d\n", \
                __FILE__, __LINE__); } while(0)
-
-
 namespace WebCore {
 
 struct WidgetPrivate
 {
-    WidgetPrivate() : m_parent(0), m_widget(new QWidget) {}
+    WidgetPrivate() : m_parent(0), m_widget(0) { }
     ~WidgetPrivate() { delete m_widget; }
 
     QWidget* m_parent;
@@ -66,68 +64,74 @@
 
 void Widget::setClient(WidgetClient* c)
 {
-   notImplemented();
+    notImplemented();
 }
 
 WidgetClient* Widget::client() const
 {
-   notImplemented();
-   return 0;
+    notImplemented();
+    return 0;
 }
 
 IntRect Widget::frameGeometry() const
 {
+    if (!data->m_widget)
+        return IntRect();
+
     qDebug() << "Widget::frameGeometry(), this=" << this << " returning: " << \
data->m_widget->geometry();  return data->m_widget->geometry();
 }
 
 bool Widget::hasFocus() const
 {
-   return false;
+    if (!data->m_widget)
+        return false;
+
+    return data->m_widget->hasFocus();
 }
 
 void Widget::setFocus()
 {
-   notImplemented();
+    if (data->m_widget)
+        data->m_widget->setFocus();
 }
 
 void Widget::clearFocus()
 {
-   notImplemented();
+    if (data->m_widget)
+        data->m_widget->clearFocus();
 }
 
 const Font& Widget::font() const
 {
-   notImplemented();
-   return data->m_font;
+    return data->m_font;
 }
 
 void Widget::setFont(const Font& font)
 {
-   notImplemented();
+    notImplemented();
 }
 
 void Widget::setCursor(const Cursor& cursor)
 {
-   if (data->m_widget)
-       data->m_widget->setCursor(cursor.impl());
+    if (data->m_widget)
+        data->m_widget->setCursor(cursor.impl());
 }
 
 void Widget::show()
 {
-    qDebug() << "Widget::show()";
-    data->m_widget->show();
+    if (data->m_widget)
+        data->m_widget->show();
 }
 
 void Widget::hide()
 {
-    qDebug() << "Widget::hide()";
-    data->m_widget->hide();
+    if (data->m_widget)
+       data->m_widget->hide();
 }
 
 void Widget::setQWidget(QWidget *child)
 {
-    qDebug() << "Widget::setQWidget(before=" << data->m_widget << " now=" << child \
<< ")";  delete data->m_widget;
     data->m_widget = child;
 }
@@ -139,7 +143,6 @@
 
 void Widget::setParentWidget(QWidget* parent)
 {
-    qDebug("Widget::setParentWidget(), parent=%p", parent);
     data->m_parent = parent;
 }
 
@@ -150,67 +153,84 @@
 
 void Widget::setFrameGeometry(const IntRect& r)
 {
-   IntRect hack = r;
-   IntRect current = data->m_widget->frameGeometry();
+    if (!data->m_widget)
+        return;
+
+    IntRect hack = r;
+    IntRect current = data->m_widget->frameGeometry();
  
-   // TODO: Find out why there is 0x0 given as w/h.
-   if(hack.width() == 0)
-       hack.setWidth(current.width()); 
-   if(hack.height() == 0)
-       hack.setHeight(current.height());
+    // TODO: Find out why there is 0x0 given as w/h.
+    if(hack.width() == 0)
+        hack.setWidth(current.width()); 
+    if(hack.height() == 0)
+        hack.setHeight(current.height());
   
-    qDebug() << "Widget::setFrameGeometry(), this=" << this << " r=" << r << " was=" \
                << current << " CORRECTED TO: " << hack;
-    data->m_widget->setGeometry(hack);
+     qDebug() << "Widget::setFrameGeometry(), this=" << this << " r=" << r << " \
was=" << current << " CORRECTED TO: " << hack; +     \
data->m_widget->setGeometry(hack);  }
 
 IntPoint Widget::mapFromGlobal(const IntPoint& p) const
 {
-   return data->m_widget->mapFromGlobal(p);
+    if (!data->m_widget)
+        return IntPoint();
+
+    return data->m_widget->mapFromGlobal(p);
 }
 
 float Widget::scaleFactor() const
 {
-   return 1.0f;
+    return 1.0f;
 }
 
 GraphicsContext* Widget::lockDrawingFocus()
 {
-   notImplemented();
-   return 0;
+    notImplemented();
+    return 0;
 }
 
 void Widget::unlockDrawingFocus(GraphicsContext*)
 {
-   notImplemented();
+    notImplemented();
 }
 
-void Widget::paint(GraphicsContext*, IntRect const&) {
-   notImplemented();
+void Widget::paint(GraphicsContext*, IntRect const&)
+{
+    notImplemented();
 }
 
-void Widget::enableFlushDrawing() {
-   notImplemented();
+void Widget::enableFlushDrawing()
+{
+    notImplemented();
 }
 
-bool Widget::isEnabled() const {
-  return data->m_widget->isEnabled();
+bool Widget::isEnabled() const
+{
+    if (!data->m_widget)
+        return false;
+
+    return data->m_widget->isEnabled();
 }
 
-void Widget::setIsSelected(bool) {
-   notImplemented();
+void Widget::setIsSelected(bool)
+{
+    notImplemented();
 }
 
-void Widget::disableFlushDrawing() {
-   notImplemented();
+void Widget::disableFlushDrawing()
+{
+    notImplemented();
 }
 
-void Widget::setEnabled(bool en) {
-   data->m_widget->setEnabled(en);
+void Widget::setEnabled(bool en)
+{
+    if (data->m_widget)
+        data->m_widget->setEnabled(en);
 }
 
-Widget::FocusPolicy Widget::focusPolicy() const {
-   notImplemented();
-   return NoFocus;
+Widget::FocusPolicy Widget::focusPolicy() const
+{
+    notImplemented();
+    return NoFocus;
 }
 
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic