Use Webkit in QT to write simple source code Case Analysis

Source: Internet
Author: User
Tags gtk

QTUsed inWebkitSimple Writing of source code case analysis is the content to be introduced in this article, mainly to learn about today's ResearchWebkitThis is something that is not described here. You don't have to read it if you don't understand it.

Here we useQtThe Code branch is mainly used for analysis. complicated analysis also exists for individuals, but after all, it involves some confidential issues, so it is inconvenient to make public .)

JaveScripeCore: the core program for executing commit Crip, which contains the script parser, analyzer, and execution program.

WebCore: The core component of the browser. It can be viewed as a core library for Http parsing and display, including the distribution and processing of various scripts and the organization of the UI, it processes basic GUI operations, event-related, network, data IO, and image codec. It is a core component.

Other libraries: Support for libraries on Other platforms, such as libsqlite, libpng, and libjepg.

Platform: supported by the Platform.

Here we use QT as an analysis case

WebCore

WebCore \ platform \ qt:

ClipboardQT: Implements management clipboard Packaging

ContextMenuQt and ContextMenuItemQt: an encapsulation of menu information, which does not support GUI graphics.

CookieJarQt: uses the cookitAPI encapsulated by webkit to manage cookie information.

CursorQt: provides a variety of State cursor styles for the encapsulation of the cursor.

DragDataQt: used to temporarily store drag-and-drop object data in the UI. qmierdata is required in QT and can be implemented on ARM without consideration.

DragImageQt: similar to the above functions, but not supported.

FileChooserQt: used to open a local file. It contains a call to the GUI dialog box.

FileSystemQt: functions used to provide IO support for files.

KeyboardCodes. h: the key values are defined based on different platforms.

Localizations: provides specific strings returned from different platforms, such as Download Image, which are obtained in the form of functions.

MenuEventProxy: useless file, which may be supported by QT of previous versions. The new version is useless.

MIMETypeRegistryQT: the custom MIME type is returned through the input MIME string. It is only used to process the string.

PasteboardQt: For the clipboard encapsulation, encapsulate some work to set the clipboard content

PlatformKeyboardEventQt: mainly two platform-related key conversion functions, which need to be transplanted.

PlatformMouseEventQt: encapsulation of mouse events

PlatformScreenQt: encapsulates the function for getting the window size, which needs to be rewritten.

PlatformScrollBarQt: encapsulate the scroll bars used by the platform. Different GUI engines use different scroll bar interfaces. It is troublesome to transplant them. You need to rewrite them with the upper-layer code.

PlugInInfoStoreQt: Plug-In manager. You can refer to the GTK solution to discard the support.

PopupMenuQt: encapsulation of pop-up menus

QWebPopup: It seems that the pop-up menu is implemented. The practice in this menu is to use qcombobox to open a virtual menu.

RenderThemeQt

ScreenQt: useless, not compiled

ScrollViewQt: A required control that encapsulates some interfaces.

SearchPopupMenuQt: useless. All functions return null.

SharedTimerQt: a timer. QT uses Qtimer for encapsulation.

SoundQt: Call the function of a system ringtone

SystemTimeQt: returns the system time.

TemporaryLinkStubs: QT and GTK are not implemented and can be ignored.

ThreadingQt: it is mainly used to encapsulate some threads that need to be supported. The implementation of QT is not the same as that of Gtk and is mostly useless. ms only needs to implement the callOnMainThread function.

WheelEventQt: implementation is required. The purpose is unknown.

WidgetQt: The encapsulation of a window varies by platform. You can use one of them as a reference.

WebCore \ platform \ text:

The code is mainly used to process the basic characters in different platforms. webkit itself provides a character mechanism that can be used or modified based on the critical parts of the Platform, such as QT and mac

WebCore \ platform \ network:

ResourceResponse. h: Write a derived class to be implemented, but it has no practical significance in qt. It is implemented in mac and cf.

The remaining files are some auxiliary classes for Http services. They are hard to understand because they do not have the overall architecture concept.

WebCore \ platform \ graphics:

AffineTransformQt. cpp: class function encapsulation for geometric transformation of basic platform Images

ColorQt: class that encapsulates the Color attribute

FloatPointQt: a package of the Float point Attribute Class

FloatRectQt: rectangular class packaging of floating point attributes

FontCacheQt

FontCustomPlatformData: Memory font management is hardly implemented except for mac. You can refer to qt's practice.

FontQt: encapsulation of basic font operations

GraphicsContextQt: additional upper-layer encapsulation of basic painting

IconQt: class for Icon Processing

ImageBufferQt: several functions for Image processing, which may be used for intermediate data conversion

ImageDecoderQt: an image processing interface class with complicated implementation

ImageQt: an image interface class. Many implementations depend on external implementations and are complex.

ImageSourceQt: Another encapsulation of the above two files also implements image operation details.

IntPointQt, IntRectQt, and IntSizeQt: these three classes are just like the names. They are only an encapsulation of the data structure classes.

PathQt: an encapsulation of QPainterPath, which does not exist on other platforms.

SimpleFontData: For another character encapsulation, QT has no implementation function, and other platforms have implementation

Webkit Section

Many extensions of many Webcore parts are implemented through the code in external Webkit, and the objects that require Webkit are integrated by the original class of Webcore, the most important part is the network and data I/O. It reads network or local data resources through Webkit objects. In addition, it is implemented through the Task Mode in the thread, there is a task queue for sending and receiving, and if there is another Page, it is done through another task queue.

Data IO process:

The first is the loader (***) called by the upper layer, which is a URL or a local file. Package the parameters one step after packaging, and finally transfer them to the QWebNetworkInterface: addJob function, add a new task in the task queue. If it is a local file, it is read in the form of FileIO. If it is Http, The QHttp class object is started for IO until data is obtained.

After the data is received, it is adjusted

 
 
  1. MainResourceLoader::didFinishLoading  
  2. FrameLoader::finishedLoading  
  3. DocumentLoader::finishedLoading 

Data analysis and GUI refreshing are involved.

Therefore, we can see that in addition to the need to port the GUI, there is still a lot of network work to be done,QTThe version is used for Http sending and receiving through the Http class. The Mac process andQTJust like, you need to consider porting an Http open source library for sending and receiving.

Supplement: I have read the CURL library and supported Http methods and parsing, but I will list the library required by the CURL library here. For CURL, I have not made any additional analysis.

Summary:QTUsed inWebkitI have briefly written the content of source code case analysis and hope this article will help you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.