From 6882a04fb36642862b11efe514251d32070c3d65 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Thu, 25 Aug 2016 19:20:41 +0300 Subject: Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443) Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev --- Source/WebCore/html/HTMLStyleElement.cpp | 200 ++++++------------------------- 1 file changed, 36 insertions(+), 164 deletions(-) (limited to 'Source/WebCore/html/HTMLStyleElement.cpp') diff --git a/Source/WebCore/html/HTMLStyleElement.cpp b/Source/WebCore/html/HTMLStyleElement.cpp index e2d04841c..51c6f6ae2 100644 --- a/Source/WebCore/html/HTMLStyleElement.cpp +++ b/Source/WebCore/html/HTMLStyleElement.cpp @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2003, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2003, 2010, 2013 Apple Inc. All rights reserved. * (C) 2007 Rob Buis (buis@kde.org) * * This library is free software; you can redistribute it and/or @@ -24,14 +24,12 @@ #include "config.h" #include "HTMLStyleElement.h" -#include "Attribute.h" -#include "ContextFeatures.h" #include "Document.h" #include "Event.h" #include "EventSender.h" #include "HTMLNames.h" #include "MediaList.h" -#include "ScriptEventListener.h" +#include "RuntimeEnabledFeatures.h" #include "ScriptableDocumentParser.h" #include "ShadowRoot.h" #include "StyleSheetContents.h" @@ -42,16 +40,15 @@ using namespace HTMLNames; static StyleEventSender& styleLoadEventSender() { - DEFINE_STATIC_LOCAL(StyleEventSender, sharedLoadEventSender, (eventNames().loadEvent)); + static NeverDestroyed sharedLoadEventSender(eventNames().loadEvent); return sharedLoadEventSender; } -inline HTMLStyleElement::HTMLStyleElement(const QualifiedName& tagName, Document* document, bool createdByParser) +inline HTMLStyleElement::HTMLStyleElement(const QualifiedName& tagName, Document& document, bool createdByParser) : HTMLElement(tagName, document) - , StyleElement(document, createdByParser) + , m_styleSheetOwner(document, createdByParser) , m_firedLoad(false) , m_loadedSheet(false) - , m_scopedStyleRegistrationState(NotRegistered) { ASSERT(hasTagName(styleTag)); } @@ -60,185 +57,60 @@ HTMLStyleElement::~HTMLStyleElement() { // During tear-down, willRemove isn't called, so m_scopedStyleRegistrationState may still be RegisteredAsScoped or RegisteredInShadowRoot here. // Therefore we can't ASSERT(m_scopedStyleRegistrationState == NotRegistered). - StyleElement::clearDocumentData(document(), this); + m_styleSheetOwner.clearDocumentData(document(), *this); - styleLoadEventSender().cancelEvent(this); + styleLoadEventSender().cancelEvent(*this); } -PassRefPtr HTMLStyleElement::create(const QualifiedName& tagName, Document* document, bool createdByParser) +Ref HTMLStyleElement::create(const QualifiedName& tagName, Document& document, bool createdByParser) { - return adoptRef(new HTMLStyleElement(tagName, document, createdByParser)); + return adoptRef(*new HTMLStyleElement(tagName, document, createdByParser)); } void HTMLStyleElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { - if (name == titleAttr && m_sheet) - m_sheet->setTitle(value); - else if (name == scopedAttr && ContextFeatures::styleScopedEnabled(document())) - scopedAttributeChanged(!value.isNull()); - else if (name == mediaAttr && inDocument() && document()->renderer() && m_sheet) { - m_sheet->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(value)); - document()->styleResolverChanged(RecalcStyleImmediately); - } else + if (name == titleAttr && sheet()) + sheet()->setTitle(value); + else if (name == mediaAttr) { + m_styleSheetOwner.setMedia(value); + if (sheet()) { + sheet()->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(value)); + if (inDocument() && document().hasLivingRenderTree()) + document().styleResolverChanged(RecalcStyleImmediately); + } + } else if (name == typeAttr) + m_styleSheetOwner.setContentType(value); + else HTMLElement::parseAttribute(name, value); } -void HTMLStyleElement::scopedAttributeChanged(bool scoped) -{ - ASSERT(ContextFeatures::styleScopedEnabled(document())); - - if (!inDocument()) - return; - - if (scoped) { - // As any