OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 void FullscreenController::DidEnterFullscreen() { | 67 void FullscreenController::DidEnterFullscreen() { |
68 // |Browser::EnterFullscreenModeForTab()| can enter fullscreen without going | 68 // |Browser::EnterFullscreenModeForTab()| can enter fullscreen without going |
69 // through |Fullscreen::requestFullscreen()|, in which case there will be no | 69 // through |Fullscreen::requestFullscreen()|, in which case there will be no |
70 // fullscreen element. Do nothing. | 70 // fullscreen element. Do nothing. |
71 if (state_ != State::kEnteringFullscreen) | 71 if (state_ != State::kEnteringFullscreen) |
72 return; | 72 return; |
73 | 73 |
74 UpdatePageScaleConstraints(false); | 74 UpdatePageScaleConstraints(false); |
75 web_view_base_->SetPageScaleFactor(1.0f); | 75 web_view_base_->SetPageScaleFactor(1.0f); |
76 if (web_view_base_->MainFrame()->IsWebLocalFrame()) | 76 if (web_view_base_->MainFrame()->IsWebLocalFrame()) |
77 web_view_base_->MainFrame()->SetScrollOffset(WebSize()); | 77 web_view_base_->MainFrame()->ToWebLocalFrame()->SetScrollOffset(WebSize()); |
dcheng
2017/06/16 23:52:20
+alexmos, is there anything more we need to do her
alexmos
2017/06/17 00:04:02
I don't think so - I think these only need to be d
| |
78 web_view_base_->SetVisualViewportOffset(FloatPoint()); | 78 web_view_base_->SetVisualViewportOffset(FloatPoint()); |
79 | 79 |
80 state_ = State::kFullscreen; | 80 state_ = State::kFullscreen; |
81 | 81 |
82 // Notify all local frames that we have entered fullscreen. | 82 // Notify all local frames that we have entered fullscreen. |
83 for (Frame* frame = web_view_base_->GetPage()->MainFrame(); frame; | 83 for (Frame* frame = web_view_base_->GetPage()->MainFrame(); frame; |
84 frame = frame->Tree().TraverseNext()) { | 84 frame = frame->Tree().TraverseNext()) { |
85 if (!frame->IsLocalFrame()) | 85 if (!frame->IsLocalFrame()) |
86 continue; | 86 continue; |
87 if (Document* document = ToLocalFrame(frame)->GetDocument()) { | 87 if (Document* document = ToLocalFrame(frame)->GetDocument()) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 | 144 |
145 // We need to store these values here rather than in |didEnterFullscreen()| | 145 // We need to store these values here rather than in |didEnterFullscreen()| |
146 // since by the time the latter is called, a Resize has already occured, | 146 // since by the time the latter is called, a Resize has already occured, |
147 // clamping the scroll offset. Don't save values if we're still waiting to | 147 // clamping the scroll offset. Don't save values if we're still waiting to |
148 // restore a previous set. This can happen if we exit and quickly reenter | 148 // restore a previous set. This can happen if we exit and quickly reenter |
149 // fullscreen without performing a layout. | 149 // fullscreen without performing a layout. |
150 if (state_ == State::kInitial) { | 150 if (state_ == State::kInitial) { |
151 initial_page_scale_factor_ = web_view_base_->PageScaleFactor(); | 151 initial_page_scale_factor_ = web_view_base_->PageScaleFactor(); |
152 initial_scroll_offset_ = | 152 initial_scroll_offset_ = |
153 web_view_base_->MainFrame()->IsWebLocalFrame() | 153 web_view_base_->MainFrame()->IsWebLocalFrame() |
154 ? web_view_base_->MainFrame()->GetScrollOffset() | 154 ? web_view_base_->MainFrame()->ToWebLocalFrame()->GetScrollOffset() |
155 : WebSize(); | 155 : WebSize(); |
156 initial_visual_viewport_offset_ = web_view_base_->VisualViewportOffset(); | 156 initial_visual_viewport_offset_ = web_view_base_->VisualViewportOffset(); |
157 initial_background_color_override_enabled_ = | 157 initial_background_color_override_enabled_ = |
158 web_view_base_->BackgroundColorOverrideEnabled(); | 158 web_view_base_->BackgroundColorOverrideEnabled(); |
159 initial_background_color_override_ = | 159 initial_background_color_override_ = |
160 web_view_base_->BackgroundColorOverride(); | 160 web_view_base_->BackgroundColorOverride(); |
161 } | 161 } |
162 | 162 |
163 // If already entering fullscreen, just wait. | 163 // If already entering fullscreen, just wait. |
164 if (state_ == State::kEnteringFullscreen) | 164 if (state_ == State::kEnteringFullscreen) |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 } | 252 } |
253 } | 253 } |
254 } | 254 } |
255 | 255 |
256 void FullscreenController::DidUpdateLayout() { | 256 void FullscreenController::DidUpdateLayout() { |
257 if (state_ != State::kNeedsScrollAndScaleRestore) | 257 if (state_ != State::kNeedsScrollAndScaleRestore) |
258 return; | 258 return; |
259 | 259 |
260 web_view_base_->SetPageScaleFactor(initial_page_scale_factor_); | 260 web_view_base_->SetPageScaleFactor(initial_page_scale_factor_); |
261 if (web_view_base_->MainFrame()->IsWebLocalFrame()) { | 261 if (web_view_base_->MainFrame()->IsWebLocalFrame()) { |
262 web_view_base_->MainFrame()->SetScrollOffset( | 262 web_view_base_->MainFrame()->ToWebLocalFrame()->SetScrollOffset( |
263 WebSize(initial_scroll_offset_)); | 263 WebSize(initial_scroll_offset_)); |
264 } | 264 } |
265 web_view_base_->SetVisualViewportOffset(initial_visual_viewport_offset_); | 265 web_view_base_->SetVisualViewportOffset(initial_visual_viewport_offset_); |
266 // Background color override was already restored when | 266 // Background color override was already restored when |
267 // fullscreenElementChanged([..], nullptr) was called while exiting. | 267 // fullscreenElementChanged([..], nullptr) was called while exiting. |
268 | 268 |
269 state_ = State::kInitial; | 269 state_ = State::kInitial; |
270 } | 270 } |
271 | 271 |
272 void FullscreenController::UpdatePageScaleConstraints(bool remove_constraints) { | 272 void FullscreenController::UpdatePageScaleConstraints(bool remove_constraints) { |
(...skipping 14 matching lines...) Expand all Loading... | |
287 // again to ensure the final constraints pick up the latest contents size. | 287 // again to ensure the final constraints pick up the latest contents size. |
288 web_view_base_->DidChangeContentsSize(); | 288 web_view_base_->DidChangeContentsSize(); |
289 if (web_view_base_->MainFrameImpl() && | 289 if (web_view_base_->MainFrameImpl() && |
290 web_view_base_->MainFrameImpl()->GetFrameView()) | 290 web_view_base_->MainFrameImpl()->GetFrameView()) |
291 web_view_base_->MainFrameImpl()->GetFrameView()->SetNeedsLayout(); | 291 web_view_base_->MainFrameImpl()->GetFrameView()->SetNeedsLayout(); |
292 | 292 |
293 web_view_base_->UpdateMainFrameLayoutSize(); | 293 web_view_base_->UpdateMainFrameLayoutSize(); |
294 } | 294 } |
295 | 295 |
296 } // namespace blink | 296 } // namespace blink |
OLD | NEW |