KHTML
KHTML is a discontinued web browser rendering engine developed by the KDE project as the core HTML rendering component for the Konqueror web browser and various KDE applications.[1][2] Originating in the late 1990s, KHTML underwent a significant rewrite in March 1999 by Lars Knoll, adopting the W3C Document Object Model (DOM) as its internal representation to improve standards compliance.[3] In mid-1999, JavaScript support was added through Harri Porten's KJS engine, followed by CSS implementation between January and March 2000 by Knoll, Antti Koivisto, and Dirk Mueller, establishing KHTML as a lightweight yet capable web engine comparable to contemporaries like Gecko and Trident.[3][2] The engine supported key web standards, including XML/HTML4 parsing, DOM Levels 1 and 2, ECMA-262 JavaScript 1.5 compliance, CSS 2.1 (with partial CSS3 elements), and Java applet rendering.[2][4] KHTML's architecture emphasized modularity and integration with Qt, enabling its use beyond browsing in email clients and other KDE tools for embedding web content.[1][5] Its most notable legacy stems from Apple's 2001 fork, which evolved into the WebKit engine, powering Safari, the iPhone browser, and influencing further derivatives like Blink in Google Chrome, thus extending KHTML's impact to the majority of modern web browsers.[6][3] Development of KHTML ceased with the transition to KDE Frameworks 6 in 2024, though it remains available in legacy KDE 5 branches for Konqueror.[7]History
Origins
KHTML's development began in 1998 as an initiative by contributors to the KDE project, notably Torben Weis and Martin Jones, who developed the precursor KDE HTML Widget (khtmlw) providing basic HTML 3.2 support. This laid the groundwork for a dedicated layout engine aimed at the Konqueror web browser and file manager. The effort sought to deliver a seamless, integrated browsing experience within the KDE desktop environment, replacing earlier rudimentary HTML rendering components and enabling Konqueror to serve as a unified tool for web navigation and file handling.[8][2] The primary motivations behind KHTML were to engineer a lightweight rendering engine that prioritized web standards compliance, offering an open-source counterpoint to dominant proprietary solutions such as Microsoft's Internet Explorer. By building upon the Qt framework, the developers ensured cross-platform portability and efficient integration with KDE's component-based architecture, known as KParts, which allowed modular embedding of the engine into various applications without excessive overhead. This approach emphasized simplicity and adherence to specifications like HTML 4.0, focusing initially on core rendering capabilities while deferring advanced scripting features. Lars Knoll led a significant rewrite in 1999 to advance these goals.[2][9] KHTML's first public integration occurred with the release of Konqueror in KDE 2.0 on October 23, 2000, where it handled basic HTML 4.0 rendering but lacked built-in JavaScript support, relying instead on external modules for enhanced functionality. Early versions provided basic HTML 4.0 rendering, with support for CSS Level 2 and DOM Level 1 added in subsequent iterations starting in 1999-2000. Early adopters appreciated its standards-oriented design, though full compliance evolved over subsequent iterations.[2] A significant early challenge for the KHTML team was operating with limited resources in comparison to larger endeavors like the Mozilla project, which boasted greater funding and developer contributions. This constraint influenced the adoption of a modular design from the outset, leveraging KDE's KParts system to facilitate incremental improvements and easier maintenance without overhauling the entire codebase. Despite these hurdles, the engine's focus on efficiency and interoperability positioned it as a viable option for resource-conscious Unix-like systems.[9][8]Rewrite and Improvements
In the early 2000s, KHTML underwent a significant refactoring led by Lars Knoll and other KDE developers to improve its performance, modularity, and compliance with web standards. The effort began with a complete rewrite committed to the KDE CVS repository in August 1999 by Knoll, which adopted the W3C Document Object Model (DOM) as the engine's internal representation. This change separated HTML parsing from layout calculations, resulting in better speed and reduced memory usage compared to the initial widget-based design.[10] From January to March 2000, Knoll collaborated with Antti Koivisto and Dirk Mueller to add comprehensive support for Cascading Style Sheets (CSS) and stabilize KHTML's architecture, making it suitable for rendering complex web applications on par with engines like Gecko and Trident. Contributions from the broader KDE community expanded during this phase, culminating in the integration of DOM Level 2 support by 2002, which enhanced dynamic content manipulation through refcounted memory management and fuller adherence to W3C specifications.[3][2] Further enhancements focused on standards compliance, with KHTML achieving full passage of the Acid1 test—validating CSS1 implementation—by the release of Konqueror 3 in 2002. Support for CSS 2.1 was progressively strengthened from 2003 through 2005, enabling more reliable styling and layout for modern web pages within the KDE 3 framework. These refactorings collectively transformed KHTML into a mature, efficient engine, prioritizing conceptual adherence to web standards over exhaustive feature lists.[11][2]Expansion with Modules
In the early 2000s, KHTML's functionality was extended through the development of dedicated modules that addressed key gaps in web scripting and multimedia rendering, allowing Konqueror to handle dynamic content more effectively while maintaining a lightweight core. One pivotal addition was the KJS engine, created in 1999 by Harri Porten to fulfill Konqueror's need for ECMAScript-compliant JavaScript execution.[3] This module integrated seamlessly with KHTML's document object model, enabling the interpretation of embedded scripts and supporting interactive web elements without bloating the primary rendering pipeline.[12] Building on this foundation, the KSVG module was initiated in 2003 to introduce experimental support for Scalable Vector Graphics (SVG) 1.1, focusing on vector-based rendering for diagrams, charts, and animations within Konqueror.[13] As a KPart component, KSVG provided partial implementation of the W3C standard, including features like rotated text and ECMAScript-driven interactivity, though full completion was never achieved due to shifting priorities in KDE development.[13] This extension enhanced KHTML's ability to display high-quality, resolution-independent graphics, marking an early open-source effort toward vector web standards compliance. Complementing these were image-handling enhancements via the KImageIO library and associated plugins, developed between 2002 and 2004 to broaden support for common formats such as PNG and JPEG in Konqueror and other KDE applications.[14] KImageIO served as an interface for loading and saving images through a plugin architecture, allowing dynamic registration of formats like those in kdelibs without requiring recompilation of the core engine.[15] KHTML's modular design facilitated optional loading of these components—such as KJS for scripting, KSVG for vectors, and KImageIO for multimedia—ensuring the engine remained efficient for basic browsing while scaling for advanced needs. By 2005, with integrations like those in KDE 3.4 and 3.5, these modules contributed to Konqueror's strong compliance with web standards, including near-full CSS 2.1 support and successful passage of the Acid2 test, covering a substantial portion of contemporary web features.[16][17]Discontinuation
Active development of KHTML began to slow after 2010 as the KDE project shifted focus toward QtWebEngine, a Chromium-based rendering engine, to provide better support for modern web standards in applications like Konqueror.[18] This transition was driven by the need for improved compatibility with evolving web technologies, as KHTML struggled to keep pace with rapid advancements in browser engines.[19] The last significant updates to KHTML occurred in 2016, primarily consisting of security patches and minor maintenance to ensure compatibility with KDE Frameworks 5 (KF5).[20] During this period, efforts centered on addressing vulnerabilities rather than adding new features, leading to stagnation in support for HTML5 and CSS3 specifications as development resources diminished.[21] In 2023, KDE officially announced the discontinuation of KHTML, with the engine removed from KDE Frameworks 6 (KF6) upon its release in 2024; the GitHub and GitLab repositories were archived, preserving the KF5 branch as the final maintained version.[22][20] This decision was influenced by the overwhelming dominance of the WebKit and Blink rendering engine ecosystems, which rendered ongoing maintenance of KHTML unsustainable for the KDE community.[23] Concurrently, Konqueror pivoted toward integration with QtWebEngine by around 2016, while the KDE project promoted Falkon—a new browser based on QtWebEngine—as the primary web browsing solution starting in 2017.[24][25]Technical Features
Core Rendering Engine
KHTML's core rendering engine processes web content through a series of stages, beginning with parsing the HTML and CSS to construct the necessary data structures for layout and display. The parsing stage employs an HTML tokenizer that converts the raw HTML source into a Document Object Model (DOM) tree using a state machine-based approach. This tokenizer is instantiated via the DocumentImpl::open() method and can be either an HTMLTokenizer for standard HTML or an XMLTokenizer for XML documents.[26] The CSS parser then processes stylesheet rules, organizing them into computed styles that are applied to DOM nodes according to the CSS cascade rules, determining the visual properties for each element. In the layout phase, KHTML computes the box model for elements, distinguishing between block and inline boxes to determine their geometric properties such as width, height, margins, and padding. This computation follows the standard CSS box model, where content, padding, borders, and margins are calculated relative to the containing block. Reflow is triggered whenever content, styles, or viewport dimensions change, recalculating positions and sizes incrementally to update the layout tree efficiently; it supports positioning schemes including fixed, relative, absolute, and static. The render tree, a parallel structure to the DOM, represents visual elements and includes anonymous render objects inserted to wrap inline content or handle structural needs as per CSS specifications, such as enclosing the string "more text" in an anonymous block.[26][27] The painting stage rasterizes the layout results onto the screen using Qt's graphics primitives, primarily through the QPainter class for drawing elements like text, images, and borders. Elements with z-index or opacity are handled in separate layers to enable compositing without full repaints, leveraging Qt's clipping and transformation capabilities for efficient rendering. The KHTMLView class manages this process, invoking paint methods with QPainter instances clipped to specific regions (e.g., int clipx, int clipy, int clipw, int cliph).[28]Standards Compliance
KHTML achieved full compliance with the HTML 4.01 specification early in its development, positioning it as one of the first browser engines to prioritize web standards from inception.[2] By 2005, with the release of KDE 3.5, KHTML demonstrated strong adherence to CSS 2.1, becoming the second engine after Safari to fully pass the Acid2 test, which verifies rendering of complex HTML and CSS features.[29] However, support for emerging HTML5 elements remained experimental and incomplete even by 2010; for instance, basic parsing for elements like<video> and <canvas> was added in later KDE 4 releases, but full functionality was lacking without additional plugins.
In terms of CSS3, KHTML showed early leadership in specific areas, with version 3.5.6 in 2007 passing all tests in the Automated CSS3 Selectors Testsuite, outperforming contemporaries in selector support.[30] Advanced CSS3 modules like flexbox were not natively implemented, remaining unsupported in core KHTML until discontinuation, though late patches in KDE 4 series introduced partial compatibility via experimental flags. Other standards included robust basic parsing for XML and XHTML, enabling strict document handling.[2] DOM support was comprehensive for Levels 1 and 2, covering core node manipulation and events, but Level 3 features such as advanced XPath and load/save methods were only partially realized.[2] Native WebGL integration was absent, with any 3D graphics relying on external KDE modules or plugins like those based on Qt OpenGL.[31]
Testing outcomes highlighted KHTML's strengths and gaps. By 2009, Konqueror using KHTML scored 83/100 on the Acid3 test, reflecting solid progress in SVG, DOM, and JavaScript conformance but falling short of full compliance due to incomplete multimedia and animation support. Persistent limitations were evident in rendering bugs, such as incorrect placement of table footers (<tfoot>) and failure to apply frame/rules attributes, as documented in KDE's bug tracker.[32][33] Media queries saw implementation in KDE 4.1 but suffered from issues like improper responsive behavior on dynamic content resizes, also tracked in KDE reports.[31] These challenges underscored KHTML's focus on core standards while highlighting areas where ongoing maintenance was needed for evolving web specifications.