This source file includes following definitions.
- empty
- supplementName
- defaultSwitch
- dialogElementEnabled
- styleScopedEnabled
- pagePopupEnabled
- mutationEventsEnabled
- pushStateEnabled
- provideContextFeaturesTo
- provideContextFeaturesToDocumentFrom
#include "config.h"
#include "core/dom/ContextFeatures.h"
#include "RuntimeEnabledFeatures.h"
#include "core/dom/Document.h"
#include "core/page/Page.h"
namespace WebCore {
ContextFeaturesClient* ContextFeaturesClient::empty()
{
DEFINE_STATIC_LOCAL(ContextFeaturesClient, empty, ());
return ∅
}
const char* ContextFeatures::supplementName()
{
return "ContextFeatures";
}
ContextFeatures* ContextFeatures::defaultSwitch()
{
DEFINE_STATIC_REF(ContextFeatures, instance, (ContextFeatures::create(ContextFeaturesClient::empty())));
return instance;
}
bool ContextFeatures::dialogElementEnabled(Document* document)
{
if (!document)
return RuntimeEnabledFeatures::dialogElementEnabled();
return document->contextFeatures().isEnabled(document, DialogElement, RuntimeEnabledFeatures::dialogElementEnabled());
}
bool ContextFeatures::styleScopedEnabled(Document* document)
{
if (!document)
return RuntimeEnabledFeatures::styleScopedEnabled();
return document->contextFeatures().isEnabled(document, StyleScoped, RuntimeEnabledFeatures::styleScopedEnabled());
}
bool ContextFeatures::pagePopupEnabled(Document* document)
{
if (!document)
return false;
return document->contextFeatures().isEnabled(document, PagePopup, false);
}
bool ContextFeatures::mutationEventsEnabled(Document* document)
{
ASSERT(document);
if (!document)
return true;
return document->contextFeatures().isEnabled(document, MutationEvents, true);
}
bool ContextFeatures::pushStateEnabled(Document* document)
{
return document->contextFeatures().isEnabled(document, PushState, true);
}
void provideContextFeaturesTo(Page& page, ContextFeaturesClient* client)
{
RefCountedSupplement<Page, ContextFeatures>::provideTo(page, ContextFeatures::supplementName(), ContextFeatures::create(client));
}
void provideContextFeaturesToDocumentFrom(Document& document, Page& page)
{
ContextFeatures* provided = static_cast<ContextFeatures*>(RefCountedSupplement<Page, ContextFeatures>::from(page, ContextFeatures::supplementName()));
if (!provided)
return;
document.setContextFeatures(*provided);
}
}