Skip to content

Commit d25ffd3

Browse files
committed
LibWeb: Fire a DOMContentLoaded event when the new parser is finished
With this change, we can finally load and render welcome.html :^)
1 parent db6cf9b commit d25ffd3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Libraries/LibWeb/Parser/HTMLDocumentParser.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@
2424
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525
*/
2626

27+
#define PARSER_DEBUG
28+
2729
#include <AK/Utf32View.h>
2830
#include <LibWeb/DOM/Comment.h>
2931
#include <LibWeb/DOM/Document.h>
3032
#include <LibWeb/DOM/DocumentType.h>
3133
#include <LibWeb/DOM/ElementFactory.h>
34+
#include <LibWeb/DOM/Event.h>
3235
#include <LibWeb/DOM/HTMLFormElement.h>
3336
#include <LibWeb/DOM/HTMLHeadElement.h>
3437
#include <LibWeb/DOM/HTMLScriptElement.h>
@@ -65,12 +68,18 @@ void HTMLDocumentParser::run(const URL& url)
6568
for (;;) {
6669
auto optional_token = m_tokenizer.next_token();
6770
if (!optional_token.has_value())
68-
return;
71+
break;
6972
auto& token = optional_token.value();
7073

74+
#ifdef PARSER_DEBUG
7175
dbg() << "[" << insertion_mode_name() << "] " << token.to_string();
76+
#endif
7277
process_using_the_rules_for(m_insertion_mode, token);
7378
}
79+
80+
// "The end"
81+
82+
m_document->dispatch_event(Event::create("DOMContentLoaded"));
7483
}
7584

7685
void HTMLDocumentParser::process_using_the_rules_for(InsertionMode mode, HTMLToken& token)
@@ -543,7 +552,7 @@ void HTMLDocumentParser::run_the_adoption_agency_algorithm(HTMLToken& token)
543552

544553
size_t outer_loop_counter = 0;
545554

546-
//OuterLoop:
555+
//OuterLoop:
547556
if (outer_loop_counter >= 8)
548557
return;
549558

0 commit comments

Comments
 (0)