SlideShare une entreprise Scribd logo
1  sur  68
Télécharger pour lire hors ligne
Hybrid Apps (Native + Web)
       via QtWebKit

                    SF BAY MEEGO NETWORK
                         JUNE 22, 2011




      ARIYA HIDAYAT
   ENGINEERING DIRECTOR
whoami
Overview
Going Hybrid?

   Platform Integration      Security



                            App Store/
    Advanced Technologies   Marketplace
WebKit Everywhere

 Browser



 Devices



Runtime
~2000 commits/month
            History
            90000
            80000
            70000
            60000
Revisions




            50000
            40000
            30000
            20000
            10000
               0
                    0   1   2   3   4     5     6    7     8     9    10
                                        Years
Extensive Tests



 ≈ 20,000 tests    tests
                  904 MB   the rest
                           229 MB
Workflow
                             quality control


    1     Every commit needs to be reviewed



    2     Broken commit must be reverted

                     zero-regression policy
Level of Involvement
    Contributor
                       after 10-20 patches




                                              after 80 patches
                       Committer

               ≈ 150                                     Reviewer

     checks in reviewed patches              ≈ 90
                                                           accept or reject patches
WebKit Reviewers
              Apple
               39




                              Google
                                25
      Misc
       11

       1     RIM
                      Nokia
              7
                        7
Components of WebKit
        DOM              CSS

              WebCore             SVG

 HTML
                   rendering
                                        JavaScriptCore


                 WebKit Library
Platform Abstractions

       Network     Unicode      Clipboard


       Graphics     Theme        Events


       Thread     Geolocation    Timer
WebCore
Di erent “Ports”                                      graphics


GraphicsContext
                      Mac        Chromium            Qt     Gtk


                                   Skia                          Cairo
                  CoreGraphics
                                                 QPainter


                                          graphics stack
Use
Web Browsers
                          Arora




  Demo Browser         http://arora.googlecode.com

       demos/browser
QWebView, QWebPage, QWebFrame
                    QWebView (widget)




                  QWebPage (object)


                            QWebFrame (object)

                     At least one, i.e. the main frame of the page
Using WebView


 QWebView webView;
 webView.show();
 webView.setUrl(QUrl("http://meego.com"));
Contents via String


 QWebView webView;
 webView.show();
 webView.setContent("<body>Hello, MeeGo!</body>");
Contents via Resource
                      <RCC>
                          <qresource prefix="/">
                              <file>content.html</file>
                          </qresource>
                      </RCC>


QWebView webView;
webView.show();
webView.setUrl(QUrl("qrc:/content.html"));
Capture to Image

QWebPage page;
QImage image(size, QImage::Format_ARGB32_Premultiplied);
image.fill(Qt::transparent);
QPainter p(&image);
page.mainFrame()->render(&p);
p.end();
image.save(fileName);



           http://labs.qt.nokia.com/2009/01/15/capturing-web-pages/
SVG Rasterizer




     http://labs.qt.nokia.com/2008/08/06/webkit-based-svg-rasterizer/
Search + Preview




     http://labs.qt.nokia.com/2008/11/04/search-with-thumbnail-preview/
Bridging the Two Worlds
Exposing to the Web world

QWebFrame::addToJavaScriptWindowObject(QString, QObject*)



                                  Public functions
                                  Object properties
                                    Child objects
Exposing to the Web world
page()->mainFrame()->addToJavaScriptWindowObject("Dialog", new Dialog);



                 class Dialog: public QObject
                 {
                     Q_OBJECT

                 public:
                     Dialog(QObject *parent = 0);

                 public slots:
                     void showMessage(const QString& msg);
                 };
Exposing to the Web world

   <input type="button" value="Try this"
   onClick="Dialog.showMessage('You clicked me!')">




    instance of
                             public slot
   Dialog object
Signal and Slot
              signal


   foobar.modified.connect(refresh);

    QObject instance       JavaScript function


  foobar.modified.connect(obj, refresh);
                             any object
Triggering Action from Native
class Stopwatch: public QObject
{                                     Stopwatch::Stopwatch(QObject *parent)
    Q_OBJECT                              : QObject(parent)
                                          , m_index(0)
public:                               {
    Stopwatch(QObject *parent = 0);       QTimer *timer = new QTimer(this);
                                          timer->setInterval(1000);
signals:                                  connect(timer, SIGNAL(timeout()), SLOT(update()));
    void tick(int t);                     timer->start();
                                      }
private slots:
    void update();                    void Stopwatch::update()
                                      {
private:                                  emit tick(m_index++);
    int m_index;                      }
};
Triggering Action from Native
   instance of
 Stopwatch object
                                  signal


      <script>
      Stopwatch.tick.connect(function(t) {
          document.getElementById('tick').innerText = t;
      });
      </script>
Coming back to the Native

  QVariant QWebFrame::evaluateJavaScript(QString)


      mostly key-value pair
     (like JavaScript objects)
Other Bridging Solutions


                                           Custom network protocol
                                           QNetworkAccessManager




       http://labs.qt.nokia.com/2010/11/16/some-webkit-hybrid-stu /
Platform Integration

                   Menu and Menu Bar

                                              Dialogs
                          Application
   System Access



                               Notifications
Debugging


     Web Inspector




settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
Deployment

     O ine                Packaging
 Cache Manifest      QtWebKit boilerplate
  Local Storage
                               Tools

              PhoneGap
          AppUp Encapsulator
Real-world Hybrid Apps




      Ext Designer       Sencha Animator
Technologies
Key Technologies
JavaScript
Libraries and Frameworks
Content Editing




      http://labs.qt.nokia.com/2009/03/12/wysiwyg-html-editor/
Consume Web 2.0




http://labs.qt.nokia.com/2009/03/08/creating-a-google-chat-client-in-15-minutes/
Vector Graphics




           http://raphaeljs.com/polar-clock.html
Canvas-based Game




      http://ariya.blogspot.com/2010/09/invade-destroy.html
Diagrams & Visualization




    JavaScript InfoVis Toolkit   http://thejit.org/
CSS3 Animations




      http://mozillademos.org/demos/planetarium/demo.html
GPU FTW

Accelerated Composition

                                          Element    GL texture


                                               Movement
                                          Transformation matrix

http://www.webkit.org/blog-files/leaves/
Sencha Animator
Device Access




          http://ariya.github.com/js/marblebox/
WebGL for 3-D




        http://webglsamples.googlecode.com/hg/aquarium/aquarium.html
PhiloGL: WebGL Framework




            http://senchalabs.github.com/philogl/
Tools
Web Inspector
Network Log

28: GET http://www.google.com/m/gp
292: Response 200 application/xhtml+xml; charset=UTF-8 0 bytes http://www.google.com/m/gp
311: GET data:image/gif;base64,R0lGODlhiA...
312: GET data:image/gif;base64,R0lGODlhJA...
312: GET data:image/gif;base64,R0lGODlhGA...
312: Response 0 image/gif 3611 bytes data:image/gif;base64,R0lGODlhiA...
312: Finish fail data:image/gif;base64,R0lGODlhiA...
312: Response 0 image/gif 284 bytes data:image/gif;base64,R0lGODlhJA...
312: Finish fail data:image/gif;base64,R0lGODlhJA...
312: Response 0 image/gif 178 bytes data:image/gif;base64,R0lGODlhGA...
312: Finish fail data:image/gif;base64,R0lGODlhGA...
317: Response 200 application/xhtml+xml; charset=UTF-8 0 bytes http://www.google.com/m/gp
324: Finish fail http://www.google.com/m/gp
328: GET http://www.google.com/m/gn/user?...
329: Finish success http://www.google.com/m/gn/user?...
Typical Scenario
                          This is
                         awesome!




                    un
             t to r
       f orge ests
           the t
Test Framework

specrunner SpecRunner.html
5 specs, 0 failures in 0.013s

specrunner SpecRunner.html
FAIL: 5 specs, 1 failure in 0.014s




               Selenium, Watir, Squish Web, JSUnit, Jasmine,
                                 QUnit, ...
Headless WebKit

if (phantom.state.length === 0) {
    phantom.state = 'pizza';
    phantom.open('http://www.google.com/m/local?site=local&q=pizza+in+new+york');
} else {
    var list = document.querySelectorAll('div.bf');
    for (var i in list) {
        console.log(list[i].innerText);
    }
    phantom.exit();
}




                               http://phantomjs.org
UI Designer
IDE: AKShell
IDE: Cloud9
Recorder and Replayer
Get + Compile
Using git

  git clone git://git.webkit.org/WebKit.git
  cd WebKit



                       ≈ 1.2 GB .git
Build

Tools/Scripts/build-webkit --qt




      --debug for “Debug” mode
Launch

Tools/Scripts/run-launcher --qt
Conclusion
Today
       Web technologies are moving really fast
Various frameworks and libraries boost the productivity
         Hybrid approach helps the migration
                Tools need to catch-up
Future
 More bindings to the native world
 Platinum-grade productivity tools
Ubiquitous mesh and cloud solutions
THANK YOU!

         ariya.hidayat@gmail.com


         ariya.blogspot.com


         ariyahidayat

Contenu connexe

Tendances

Tendances (20)

Bootiful Development with Spring Boot and React - UberConf 2018
Bootiful Development with Spring Boot and React - UberConf 2018Bootiful Development with Spring Boot and React - UberConf 2018
Bootiful Development with Spring Boot and React - UberConf 2018
 
Clojure Web Development
Clojure Web DevelopmentClojure Web Development
Clojure Web Development
 
Seven Simple Reasons to Use AppFuse
Seven Simple Reasons to Use AppFuseSeven Simple Reasons to Use AppFuse
Seven Simple Reasons to Use AppFuse
 
Comparing JVM Web Frameworks - Rich Web Experience 2010
Comparing JVM Web Frameworks - Rich Web Experience 2010Comparing JVM Web Frameworks - Rich Web Experience 2010
Comparing JVM Web Frameworks - Rich Web Experience 2010
 
Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021
 
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
 
Choosing a Java Web Framework
Choosing a Java Web FrameworkChoosing a Java Web Framework
Choosing a Java Web Framework
 
Spring Boot APIs and Angular Apps: Get Hip with JHipster! KCDC 2019
Spring Boot APIs and Angular Apps: Get Hip with JHipster! KCDC 2019Spring Boot APIs and Angular Apps: Get Hip with JHipster! KCDC 2019
Spring Boot APIs and Angular Apps: Get Hip with JHipster! KCDC 2019
 
Mobile Development with Ionic, React Native, and JHipster - AllTheTalks 2020
Mobile Development with Ionic, React Native, and JHipster - AllTheTalks 2020Mobile Development with Ionic, React Native, and JHipster - AllTheTalks 2020
Mobile Development with Ionic, React Native, and JHipster - AllTheTalks 2020
 
How to Win at UI Development in the World of Microservices - THAT Conference ...
How to Win at UI Development in the World of Microservices - THAT Conference ...How to Win at UI Development in the World of Microservices - THAT Conference ...
How to Win at UI Development in the World of Microservices - THAT Conference ...
 
Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020
 
Front End Development for Back End Java Developers - NYJavaSIG 2019
Front End Development for Back End Java Developers - NYJavaSIG 2019Front End Development for Back End Java Developers - NYJavaSIG 2019
Front End Development for Back End Java Developers - NYJavaSIG 2019
 
Java Web Application Security - UberConf 2011
Java Web Application Security - UberConf 2011Java Web Application Security - UberConf 2011
Java Web Application Security - UberConf 2011
 
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
 
What's New in Spring 3.1
What's New in Spring 3.1What's New in Spring 3.1
What's New in Spring 3.1
 
Bootiful Development with Spring Boot and React - SpringOne 2017
Bootiful Development with Spring Boot and React - SpringOne 2017Bootiful Development with Spring Boot and React - SpringOne 2017
Bootiful Development with Spring Boot and React - SpringOne 2017
 
Apache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-onApache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-on
 
Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020
Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020
Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020
 
JavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the CloudJavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
 
Case Study: Migrating Hyperic from EJB to Spring from JBoss to Apache Tomcat
Case Study: Migrating Hyperic from EJB to Spring from JBoss to Apache TomcatCase Study: Migrating Hyperic from EJB to Spring from JBoss to Apache Tomcat
Case Study: Migrating Hyperic from EJB to Spring from JBoss to Apache Tomcat
 

Similaire à Hybrid Apps (Native + Web) via QtWebKit

Introduction to QtWebKit
Introduction to QtWebKitIntroduction to QtWebKit
Introduction to QtWebKit
Ariya Hidayat
 
Google Developer Fest 2010
Google Developer Fest 2010Google Developer Fest 2010
Google Developer Fest 2010
Chris Ramsdale
 
Google io bootcamp_2010
Google io bootcamp_2010Google io bootcamp_2010
Google io bootcamp_2010
Chris Ramsdale
 
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Provectus
 

Similaire à Hybrid Apps (Native + Web) via QtWebKit (20)

Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
 
Introduction to QtWebKit
Introduction to QtWebKitIntroduction to QtWebKit
Introduction to QtWebKit
 
Qt & Webkit
Qt & WebkitQt & Webkit
Qt & Webkit
 
Analyzing the Performance of Mobile Web
Analyzing the Performance of Mobile WebAnalyzing the Performance of Mobile Web
Analyzing the Performance of Mobile Web
 
Writing Tools using WebKit
Writing Tools using WebKitWriting Tools using WebKit
Writing Tools using WebKit
 
Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010
 
JBoss World 2010
JBoss World 2010JBoss World 2010
JBoss World 2010
 
Google Developer Fest 2010
Google Developer Fest 2010Google Developer Fest 2010
Google Developer Fest 2010
 
Google io bootcamp_2010
Google io bootcamp_2010Google io bootcamp_2010
Google io bootcamp_2010
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS Application
 
The WebKit project
The WebKit projectThe WebKit project
The WebKit project
 
Guides To Analyzing WebKit Performance
Guides To Analyzing WebKit PerformanceGuides To Analyzing WebKit Performance
Guides To Analyzing WebKit Performance
 
From Code to Kubernetes
From Code to KubernetesFrom Code to Kubernetes
From Code to Kubernetes
 
Using Groovy to empower WebRTC Network Systems
Using Groovy to empower WebRTC Network SystemsUsing Groovy to empower WebRTC Network Systems
Using Groovy to empower WebRTC Network Systems
 
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
 
Vaadin & Web Components
Vaadin & Web ComponentsVaadin & Web Components
Vaadin & Web Components
 
Power ai image-pipeline
Power ai image-pipelinePower ai image-pipeline
Power ai image-pipeline
 
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
 
Android RenderScript on LLVM
Android RenderScript on LLVMAndroid RenderScript on LLVM
Android RenderScript on LLVM
 

Plus de Ariya Hidayat (6)

Understanding Webkit Rendering
Understanding Webkit RenderingUnderstanding Webkit Rendering
Understanding Webkit Rendering
 
Understanding Hardware Acceleration on Mobile Browsers
Understanding Hardware Acceleration on Mobile BrowsersUnderstanding Hardware Acceleration on Mobile Browsers
Understanding Hardware Acceleration on Mobile Browsers
 
Understanding Hardware Acceleration on Mobile Browsers
Understanding Hardware Acceleration on Mobile BrowsersUnderstanding Hardware Acceleration on Mobile Browsers
Understanding Hardware Acceleration on Mobile Browsers
 
JavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality AnalysisJavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality Analysis
 
Build HTML5 App (Intel Elements 2011)
Build HTML5 App (Intel Elements 2011)Build HTML5 App (Intel Elements 2011)
Build HTML5 App (Intel Elements 2011)
 
Efficient Graphics with Qt
Efficient Graphics with QtEfficient Graphics with Qt
Efficient Graphics with Qt
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Hybrid Apps (Native + Web) via QtWebKit

  • 1. Hybrid Apps (Native + Web) via QtWebKit SF BAY MEEGO NETWORK JUNE 22, 2011 ARIYA HIDAYAT ENGINEERING DIRECTOR
  • 4. Going Hybrid? Platform Integration Security App Store/ Advanced Technologies Marketplace
  • 5. WebKit Everywhere Browser Devices Runtime
  • 6. ~2000 commits/month History 90000 80000 70000 60000 Revisions 50000 40000 30000 20000 10000 0 0 1 2 3 4 5 6 7 8 9 10 Years
  • 7. Extensive Tests ≈ 20,000 tests tests 904 MB the rest 229 MB
  • 8. Workflow quality control 1 Every commit needs to be reviewed 2 Broken commit must be reverted zero-regression policy
  • 9. Level of Involvement Contributor after 10-20 patches after 80 patches Committer ≈ 150 Reviewer checks in reviewed patches ≈ 90 accept or reject patches
  • 10. WebKit Reviewers Apple 39 Google 25 Misc 11 1 RIM Nokia 7 7
  • 11. Components of WebKit DOM CSS WebCore SVG HTML rendering JavaScriptCore WebKit Library
  • 12. Platform Abstractions Network Unicode Clipboard Graphics Theme Events Thread Geolocation Timer
  • 13. WebCore Di erent “Ports” graphics GraphicsContext Mac Chromium Qt Gtk Skia Cairo CoreGraphics QPainter graphics stack
  • 14. Use
  • 15. Web Browsers Arora Demo Browser http://arora.googlecode.com demos/browser
  • 16. QWebView, QWebPage, QWebFrame QWebView (widget) QWebPage (object) QWebFrame (object) At least one, i.e. the main frame of the page
  • 17. Using WebView QWebView webView; webView.show(); webView.setUrl(QUrl("http://meego.com"));
  • 18. Contents via String QWebView webView; webView.show(); webView.setContent("<body>Hello, MeeGo!</body>");
  • 19. Contents via Resource <RCC> <qresource prefix="/"> <file>content.html</file> </qresource> </RCC> QWebView webView; webView.show(); webView.setUrl(QUrl("qrc:/content.html"));
  • 20. Capture to Image QWebPage page; QImage image(size, QImage::Format_ARGB32_Premultiplied); image.fill(Qt::transparent); QPainter p(&image); page.mainFrame()->render(&p); p.end(); image.save(fileName); http://labs.qt.nokia.com/2009/01/15/capturing-web-pages/
  • 21. SVG Rasterizer http://labs.qt.nokia.com/2008/08/06/webkit-based-svg-rasterizer/
  • 22. Search + Preview http://labs.qt.nokia.com/2008/11/04/search-with-thumbnail-preview/
  • 24. Exposing to the Web world QWebFrame::addToJavaScriptWindowObject(QString, QObject*) Public functions Object properties Child objects
  • 25. Exposing to the Web world page()->mainFrame()->addToJavaScriptWindowObject("Dialog", new Dialog); class Dialog: public QObject { Q_OBJECT public: Dialog(QObject *parent = 0); public slots: void showMessage(const QString& msg); };
  • 26. Exposing to the Web world <input type="button" value="Try this" onClick="Dialog.showMessage('You clicked me!')"> instance of public slot Dialog object
  • 27. Signal and Slot signal foobar.modified.connect(refresh); QObject instance JavaScript function foobar.modified.connect(obj, refresh); any object
  • 28. Triggering Action from Native class Stopwatch: public QObject { Stopwatch::Stopwatch(QObject *parent) Q_OBJECT : QObject(parent) , m_index(0) public: { Stopwatch(QObject *parent = 0); QTimer *timer = new QTimer(this); timer->setInterval(1000); signals: connect(timer, SIGNAL(timeout()), SLOT(update())); void tick(int t); timer->start(); } private slots: void update(); void Stopwatch::update() { private: emit tick(m_index++); int m_index; } };
  • 29. Triggering Action from Native instance of Stopwatch object signal <script> Stopwatch.tick.connect(function(t) { document.getElementById('tick').innerText = t; }); </script>
  • 30. Coming back to the Native QVariant QWebFrame::evaluateJavaScript(QString) mostly key-value pair (like JavaScript objects)
  • 31. Other Bridging Solutions Custom network protocol QNetworkAccessManager http://labs.qt.nokia.com/2010/11/16/some-webkit-hybrid-stu /
  • 32. Platform Integration Menu and Menu Bar Dialogs Application System Access Notifications
  • 33. Debugging Web Inspector settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
  • 34. Deployment O ine Packaging Cache Manifest QtWebKit boilerplate Local Storage Tools PhoneGap AppUp Encapsulator
  • 35. Real-world Hybrid Apps Ext Designer Sencha Animator
  • 40. Content Editing http://labs.qt.nokia.com/2009/03/12/wysiwyg-html-editor/
  • 42. Vector Graphics http://raphaeljs.com/polar-clock.html
  • 43. Canvas-based Game http://ariya.blogspot.com/2010/09/invade-destroy.html
  • 44. Diagrams & Visualization JavaScript InfoVis Toolkit http://thejit.org/
  • 45. CSS3 Animations http://mozillademos.org/demos/planetarium/demo.html
  • 46. GPU FTW Accelerated Composition Element GL texture Movement Transformation matrix http://www.webkit.org/blog-files/leaves/
  • 48. Device Access http://ariya.github.com/js/marblebox/
  • 49. WebGL for 3-D http://webglsamples.googlecode.com/hg/aquarium/aquarium.html
  • 50. PhiloGL: WebGL Framework http://senchalabs.github.com/philogl/
  • 51. Tools
  • 53. Network Log 28: GET http://www.google.com/m/gp 292: Response 200 application/xhtml+xml; charset=UTF-8 0 bytes http://www.google.com/m/gp 311: GET data:image/gif;base64,R0lGODlhiA... 312: GET data:image/gif;base64,R0lGODlhJA... 312: GET data:image/gif;base64,R0lGODlhGA... 312: Response 0 image/gif 3611 bytes data:image/gif;base64,R0lGODlhiA... 312: Finish fail data:image/gif;base64,R0lGODlhiA... 312: Response 0 image/gif 284 bytes data:image/gif;base64,R0lGODlhJA... 312: Finish fail data:image/gif;base64,R0lGODlhJA... 312: Response 0 image/gif 178 bytes data:image/gif;base64,R0lGODlhGA... 312: Finish fail data:image/gif;base64,R0lGODlhGA... 317: Response 200 application/xhtml+xml; charset=UTF-8 0 bytes http://www.google.com/m/gp 324: Finish fail http://www.google.com/m/gp 328: GET http://www.google.com/m/gn/user?... 329: Finish success http://www.google.com/m/gn/user?...
  • 54. Typical Scenario This is awesome! un t to r f orge ests the t
  • 55. Test Framework specrunner SpecRunner.html 5 specs, 0 failures in 0.013s specrunner SpecRunner.html FAIL: 5 specs, 1 failure in 0.014s Selenium, Watir, Squish Web, JSUnit, Jasmine, QUnit, ...
  • 56. Headless WebKit if (phantom.state.length === 0) {     phantom.state = 'pizza';     phantom.open('http://www.google.com/m/local?site=local&q=pizza+in+new+york'); } else {     var list = document.querySelectorAll('div.bf');     for (var i in list) {         console.log(list[i].innerText);     }     phantom.exit(); } http://phantomjs.org
  • 62. Using git git clone git://git.webkit.org/WebKit.git cd WebKit ≈ 1.2 GB .git
  • 63. Build Tools/Scripts/build-webkit --qt --debug for “Debug” mode
  • 66. Today Web technologies are moving really fast Various frameworks and libraries boost the productivity Hybrid approach helps the migration Tools need to catch-up
  • 67. Future More bindings to the native world Platinum-grade productivity tools Ubiquitous mesh and cloud solutions
  • 68. THANK YOU! ariya.hidayat@gmail.com ariya.blogspot.com ariyahidayat