Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2855)

Unified Diff: Source/modules/screen_orientation/ScreenOrientationController.cpp

Issue 319633007: Move WebScreenOrientationClient to WebFrameClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: m_client null check Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/screen_orientation/ScreenOrientationController.h ('k') | Source/web/WebLocalFrameImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/screen_orientation/ScreenOrientationController.cpp
diff --git a/Source/modules/screen_orientation/ScreenOrientationController.cpp b/Source/modules/screen_orientation/ScreenOrientationController.cpp
index 65adbf279560cb2eac5f8f5658391f351098dcc8..aecdcc881df2c957d559d495c1248cc43d990b1d 100644
--- a/Source/modules/screen_orientation/ScreenOrientationController.cpp
+++ b/Source/modules/screen_orientation/ScreenOrientationController.cpp
@@ -22,21 +22,22 @@ ScreenOrientationController::~ScreenOrientationController()
{
}
-void ScreenOrientationController::provideTo(Page& page, blink::WebScreenOrientationClient* client)
+void ScreenOrientationController::provideTo(LocalFrame& frame, blink::WebScreenOrientationClient* client)
{
- ScreenOrientationController* controller = new ScreenOrientationController(page, client);
- WillBeHeapSupplement<Page>::provideTo(page, supplementName(), adoptPtrWillBeNoop(controller));
+ ScreenOrientationController* controller = new ScreenOrientationController(frame, client);
+ WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), adoptPtrWillBeNoop(controller));
}
-ScreenOrientationController& ScreenOrientationController::from(Page& page)
+ScreenOrientationController& ScreenOrientationController::from(LocalFrame& frame)
{
- return *static_cast<ScreenOrientationController*>(WillBeHeapSupplement<Page>::from(page, supplementName()));
+ return *static_cast<ScreenOrientationController*>(WillBeHeapSupplement<LocalFrame>::from(frame, supplementName()));
}
-ScreenOrientationController::ScreenOrientationController(Page& page, blink::WebScreenOrientationClient* client)
- : PageLifecycleObserver(&page)
+ScreenOrientationController::ScreenOrientationController(LocalFrame& frame, blink::WebScreenOrientationClient* client)
+ : PageLifecycleObserver(frame.page())
, m_overrideOrientation(blink::WebScreenOrientationUndefined)
, m_client(client)
+ , m_frame(frame)
{
}
@@ -77,9 +78,13 @@ void ScreenOrientationController::pageVisibilityChanged()
if (page() && page()->visibilityState() == PageVisibilityStateVisible) {
blink::WebScreenOrientationType oldOrientation = m_overrideOrientation;
m_overrideOrientation = blink::WebScreenOrientationUndefined;
- LocalFrame* mainFrame = page()->mainFrame();
- if (mainFrame && oldOrientation != orientation())
- mainFrame->sendOrientationChangeEvent();
+ // FIXME: sendOrientationChangeEvent() currently send an event all the
+ // children of the frame, so it should only be called on the frame on
+ // top of the tree. We would need the embedder to call
+ // sendOrientationChangeEvent on every WebFrame part of a WebView to be
+ // able to remove this.
+ if (m_frame == m_frame.localFrameRoot() && oldOrientation != orientation())
+ m_frame.sendOrientationChangeEvent();
} else if (m_overrideOrientation == blink::WebScreenOrientationUndefined) {
// The page is no longer visible, store the last know screen orientation
// so that we keep returning this orientation until the page becomes
@@ -96,13 +101,10 @@ blink::WebScreenOrientationType ScreenOrientationController::orientation() const
return m_overrideOrientation;
}
- LocalFrame* mainFrame = page() ? page()->mainFrame() : 0;
- if (!mainFrame)
- return blink::WebScreenOrientationPortraitPrimary;
- blink::WebScreenOrientationType orientationType = screenOrientationType(mainFrame->view());
+ blink::WebScreenOrientationType orientationType = screenOrientationType(m_frame.view());
if (orientationType == blink::WebScreenOrientationUndefined) {
// The embedder could not provide us with an orientation, deduce it ourselves.
- orientationType = computeOrientation(mainFrame->view());
+ orientationType = computeOrientation(m_frame.view());
}
ASSERT(orientationType != blink::WebScreenOrientationUndefined);
return orientationType;
« no previous file with comments | « Source/modules/screen_orientation/ScreenOrientationController.h ('k') | Source/web/WebLocalFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698