#include "config.h"
#include "Screen.h"
#include "DOMWindow.h"
#include "Document.h"
#include "FloatRect.h"
#include "Frame.h"
#include "FrameView.h"
#include "Page.h"
#include "PlatformScreen.h"
#include "Quirks.h"
#include "ResourceLoadObserver.h"
#include "RuntimeEnabledFeatures.h"
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
WTF_MAKE_ISO_ALLOCATED_IMPL(Screen);
Screen::Screen(DOMWindow& window)
: DOMWindowProperty(&window)
{
}
unsigned Screen::height() const
{
auto* frame = this->frame();
if (!frame)
return 0;
if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
ResourceLoadObserver::shared().logScreenAPIAccessed(*frame->document(), ResourceLoadStatistics::ScreenAPI::Height);
return static_cast<unsigned>(frame->screenSize().height());
}
unsigned Screen::width() const
{
auto* frame = this->frame();
if (!frame)
return 0;
if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
ResourceLoadObserver::shared().logScreenAPIAccessed(*frame->document(), ResourceLoadStatistics::ScreenAPI::Width);
return static_cast<unsigned>(frame->screenSize().width());
}
unsigned Screen::colorDepth() const
{
auto* frame = this->frame();
if (!frame)
return 0;
if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
ResourceLoadObserver::shared().logScreenAPIAccessed(*frame->document(), ResourceLoadStatistics::ScreenAPI::ColorDepth);
return static_cast<unsigned>(screenDepth(frame->view()));
}
unsigned Screen::pixelDepth() const
{
auto* frame = this->frame();
if (!frame)
return 0;
if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
ResourceLoadObserver::shared().logScreenAPIAccessed(*frame->document(), ResourceLoadStatistics::ScreenAPI::PixelDepth);
auto* document = window()->document();
if (!document || !document->quirks().needsHDRPixelDepthQuirk() || !screenSupportsHighDynamicRange(frame->view()))
return static_cast<unsigned>(screenDepth(frame->view()));
return static_cast<unsigned>(screenDepth(frame->view())) + 1;
}
int Screen::availLeft() const
{
auto* frame = this->frame();
if (!frame)
return 0;
if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
ResourceLoadObserver::shared().logScreenAPIAccessed(*frame->document(), ResourceLoadStatistics::ScreenAPI::AvailLeft);
return static_cast<int>(screenAvailableRect(frame->view()).x());
}
int Screen::availTop() const
{
auto* frame = this->frame();
if (!frame)
return 0;
if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
ResourceLoadObserver::shared().logScreenAPIAccessed(*frame->document(), ResourceLoadStatistics::ScreenAPI::AvailTop);
return static_cast<int>(screenAvailableRect(frame->view()).y());
}
unsigned Screen::availHeight() const
{
auto* frame = this->frame();
if (!frame)
return 0;
if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
ResourceLoadObserver::shared().logScreenAPIAccessed(*frame->document(), ResourceLoadStatistics::ScreenAPI::AvailHeight);
return static_cast<unsigned>(screenAvailableRect(frame->view()).height());
}
unsigned Screen::availWidth() const
{
auto* frame = this->frame();
if (!frame)
return 0;
if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
ResourceLoadObserver::shared().logScreenAPIAccessed(*frame->document(), ResourceLoadStatistics::ScreenAPI::AvailWidth);
return static_cast<unsigned>(screenAvailableRect(frame->view()).width());
}
}