summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/frame/screen.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/frame/screen.cc')
-rw-r--r--chromium/third_party/blink/renderer/core/frame/screen.cc129
1 files changed, 75 insertions, 54 deletions
diff --git a/chromium/third_party/blink/renderer/core/frame/screen.cc b/chromium/third_party/blink/renderer/core/frame/screen.cc
index 2ce805d8147..835eb382387 100644
--- a/chromium/third_party/blink/renderer/core/frame/screen.cc
+++ b/chromium/third_party/blink/renderer/core/frame/screen.cc
@@ -49,12 +49,13 @@ WebScreenInfo GetScreenInfo(LocalFrame& frame) {
Screen::Screen(LocalFrame* frame) : DOMWindowClient(frame) {}
int Screen::height() const {
+ if (display_) {
+ DCHECK(RuntimeEnabledFeatures::ScreenEnumerationEnabled());
+ return display_->bounds.height();
+ }
LocalFrame* frame = GetFrame();
- if (!frame) {
- if (RuntimeEnabledFeatures::ScreenEnumerationEnabled() && display_)
- return display_->bounds.height;
+ if (!frame)
return 0;
- }
Page* page = frame->GetPage();
if (page->GetSettings().GetReportScreenSizeInPhysicalPixelsQuirk()) {
WebScreenInfo screen_info = GetScreenInfo(*frame);
@@ -65,12 +66,13 @@ int Screen::height() const {
}
int Screen::width() const {
+ if (display_) {
+ DCHECK(RuntimeEnabledFeatures::ScreenEnumerationEnabled());
+ return display_->bounds.width();
+ }
LocalFrame* frame = GetFrame();
- if (!frame) {
- if (RuntimeEnabledFeatures::ScreenEnumerationEnabled() && display_)
- return display_->bounds.width;
+ if (!frame)
return 0;
- }
Page* page = frame->GetPage();
if (page->GetSettings().GetReportScreenSizeInPhysicalPixelsQuirk()) {
WebScreenInfo screen_info = GetScreenInfo(*frame);
@@ -81,32 +83,28 @@ int Screen::width() const {
}
unsigned Screen::colorDepth() const {
+ if (display_) {
+ DCHECK(RuntimeEnabledFeatures::ScreenEnumerationEnabled());
+ return display_->color_depth;
+ }
LocalFrame* frame = GetFrame();
- if (!frame) {
- if (RuntimeEnabledFeatures::ScreenEnumerationEnabled() && display_)
- return display_->color_depth;
+ if (!frame)
return 0;
- }
return static_cast<unsigned>(GetScreenInfo(*frame).depth);
}
unsigned Screen::pixelDepth() const {
- LocalFrame* frame = GetFrame();
- if (!frame) {
- if (RuntimeEnabledFeatures::ScreenEnumerationEnabled() && display_)
- return display_->color_depth;
- return 0;
- }
- return static_cast<unsigned>(GetScreenInfo(*frame).depth);
+ return colorDepth();
}
int Screen::availLeft() const {
+ if (display_) {
+ DCHECK(RuntimeEnabledFeatures::ScreenEnumerationEnabled());
+ return display_->work_area.x();
+ }
LocalFrame* frame = GetFrame();
- if (!frame) {
- if (RuntimeEnabledFeatures::ScreenEnumerationEnabled() && display_)
- return display_->work_area.x;
+ if (!frame)
return 0;
- }
Page* page = frame->GetPage();
if (page->GetSettings().GetReportScreenSizeInPhysicalPixelsQuirk()) {
WebScreenInfo screen_info = GetScreenInfo(*frame);
@@ -117,12 +115,13 @@ int Screen::availLeft() const {
}
int Screen::availTop() const {
+ if (display_) {
+ DCHECK(RuntimeEnabledFeatures::ScreenEnumerationEnabled());
+ return display_->work_area.y();
+ }
LocalFrame* frame = GetFrame();
- if (!frame) {
- if (RuntimeEnabledFeatures::ScreenEnumerationEnabled() && display_)
- return display_->work_area.y;
+ if (!frame)
return 0;
- }
Page* page = frame->GetPage();
if (page->GetSettings().GetReportScreenSizeInPhysicalPixelsQuirk()) {
WebScreenInfo screen_info = GetScreenInfo(*frame);
@@ -133,12 +132,13 @@ int Screen::availTop() const {
}
int Screen::availHeight() const {
+ if (display_) {
+ DCHECK(RuntimeEnabledFeatures::ScreenEnumerationEnabled());
+ return display_->work_area.height();
+ }
LocalFrame* frame = GetFrame();
- if (!frame) {
- if (RuntimeEnabledFeatures::ScreenEnumerationEnabled() && display_)
- return display_->work_area.width;
+ if (!frame)
return 0;
- }
Page* page = frame->GetPage();
if (page->GetSettings().GetReportScreenSizeInPhysicalPixelsQuirk()) {
WebScreenInfo screen_info = GetScreenInfo(*frame);
@@ -149,12 +149,13 @@ int Screen::availHeight() const {
}
int Screen::availWidth() const {
+ if (display_) {
+ DCHECK(RuntimeEnabledFeatures::ScreenEnumerationEnabled());
+ return display_->work_area.width();
+ }
LocalFrame* frame = GetFrame();
- if (!frame) {
- if (RuntimeEnabledFeatures::ScreenEnumerationEnabled() && display_)
- return display_->work_area.height;
+ if (!frame)
return 0;
- }
Page* page = frame->GetPage();
if (page->GetSettings().GetReportScreenSizeInPhysicalPixelsQuirk()) {
WebScreenInfo screen_info = GetScreenInfo(*frame);
@@ -164,24 +165,28 @@ int Screen::availWidth() const {
return GetScreenInfo(*frame).available_rect.width;
}
-void Screen::Trace(blink::Visitor* visitor) {
+void Screen::Trace(Visitor* visitor) {
ScriptWrappable::Trace(visitor);
DOMWindowClient::Trace(visitor);
Supplementable<Screen>::Trace(visitor);
}
-Screen::Screen(display::mojom::blink::DisplayPtr display, bool primary)
+Screen::Screen(display::mojom::blink::DisplayPtr display,
+ bool internal,
+ bool primary)
: DOMWindowClient(static_cast<LocalFrame*>(nullptr)),
display_(std::move(display)),
+ internal_(internal),
primary_(primary) {}
int Screen::left() const {
+ if (display_) {
+ DCHECK(RuntimeEnabledFeatures::ScreenEnumerationEnabled());
+ return display_->bounds.x();
+ }
LocalFrame* frame = GetFrame();
- if (!frame) {
- if (RuntimeEnabledFeatures::ScreenEnumerationEnabled() && display_)
- return display_->bounds.x;
+ if (!frame)
return 0;
- }
Page* page = frame->GetPage();
if (page->GetSettings().GetReportScreenSizeInPhysicalPixelsQuirk()) {
WebScreenInfo screen_info = GetScreenInfo(*frame);
@@ -192,12 +197,13 @@ int Screen::left() const {
}
int Screen::top() const {
+ if (display_) {
+ DCHECK(RuntimeEnabledFeatures::ScreenEnumerationEnabled());
+ return display_->bounds.y();
+ }
LocalFrame* frame = GetFrame();
- if (!frame) {
- if (RuntimeEnabledFeatures::ScreenEnumerationEnabled() && display_)
- return display_->bounds.y;
+ if (!frame)
return 0;
- }
Page* page = frame->GetPage();
if (page->GetSettings().GetReportScreenSizeInPhysicalPixelsQuirk()) {
WebScreenInfo screen_info = GetScreenInfo(*frame);
@@ -208,37 +214,52 @@ int Screen::top() const {
}
bool Screen::internal() const {
- // TODO(http://crbug.com/994889): Implement this.
+ if (display_) {
+ DCHECK(RuntimeEnabledFeatures::ScreenEnumerationEnabled());
+ return internal_.has_value() && internal_.value();
+ }
+ // TODO(http://crbug.com/994889): Implement this for |window.screen|?
NOTIMPLEMENTED_LOG_ONCE();
return false;
}
bool Screen::primary() const {
- LocalFrame* frame = GetFrame();
- if (!frame && RuntimeEnabledFeatures::ScreenEnumerationEnabled() && display_)
+ if (display_) {
+ DCHECK(RuntimeEnabledFeatures::ScreenEnumerationEnabled());
return primary_.has_value() && primary_.value();
+ }
// TODO(http://crbug.com/994889): Implement this for |window.screen|?
NOTIMPLEMENTED_LOG_ONCE();
return false;
}
float Screen::scaleFactor() const {
+ if (display_) {
+ DCHECK(RuntimeEnabledFeatures::ScreenEnumerationEnabled());
+ return display_->device_scale_factor;
+ }
LocalFrame* frame = GetFrame();
- if (!frame) {
- if (RuntimeEnabledFeatures::ScreenEnumerationEnabled() && display_)
- return display_->device_scale_factor;
+ if (!frame)
return 0;
- }
return GetScreenInfo(*frame).device_scale_factor;
}
const String Screen::name() const {
// TODO(http://crbug.com/994889): Implement this.
NOTIMPLEMENTED_LOG_ONCE();
- LocalFrame* frame = GetFrame();
- if (!frame && RuntimeEnabledFeatures::ScreenEnumerationEnabled() && display_)
+ if (display_) {
+ DCHECK(RuntimeEnabledFeatures::ScreenEnumerationEnabled());
return "Generic Screen";
+ }
return String();
}
+int64_t Screen::DisplayId() const {
+ if (display_) {
+ DCHECK(RuntimeEnabledFeatures::ScreenEnumerationEnabled());
+ return display_->id;
+ }
+ return kInvalidDisplayId;
+}
+
} // namespace blink