Chromium Code Reviews| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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()->SetScrollOffset(WebSize()); |
| 78 web_view_base_->SetVisualViewportOffset(FloatPoint()); | 78 web_view_base_->SetVisualViewportOffset(FloatPoint()); |
| 79 | 79 |
| 80 state_ = State::kFullscreen; | 80 state_ = State::kFullscreen; |
| 81 web_view_base_->LayerTreeView()->SetIsFullscreen(true); | |
| 81 | 82 |
| 82 // Notify all local frames that we have entered fullscreen. | 83 // Notify all local frames that we have entered fullscreen. |
| 83 for (Frame* frame = web_view_base_->GetPage()->MainFrame(); frame; | 84 for (Frame* frame = web_view_base_->GetPage()->MainFrame(); frame; |
| 84 frame = frame->Tree().TraverseNext()) { | 85 frame = frame->Tree().TraverseNext()) { |
| 85 if (!frame->IsLocalFrame()) | 86 if (!frame->IsLocalFrame()) |
| 86 continue; | 87 continue; |
| 87 if (Document* document = ToLocalFrame(frame)->GetDocument()) { | 88 if (Document* document = ToLocalFrame(frame)->GetDocument()) { |
| 88 if (Fullscreen* fullscreen = Fullscreen::FromIfExists(*document)) | 89 if (Fullscreen* fullscreen = Fullscreen::FromIfExists(*document)) |
| 89 fullscreen->DidEnterFullscreen(); | 90 fullscreen->DidEnterFullscreen(); |
| 90 } | 91 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 | 260 |
| 260 web_view_base_->SetPageScaleFactor(initial_page_scale_factor_); | 261 web_view_base_->SetPageScaleFactor(initial_page_scale_factor_); |
| 261 if (web_view_base_->MainFrame()->IsWebLocalFrame()) | 262 if (web_view_base_->MainFrame()->IsWebLocalFrame()) |
| 262 web_view_base_->MainFrame()->SetScrollOffset( | 263 web_view_base_->MainFrame()->SetScrollOffset( |
| 263 WebSize(initial_scroll_offset_)); | 264 WebSize(initial_scroll_offset_)); |
| 264 web_view_base_->SetVisualViewportOffset(initial_visual_viewport_offset_); | 265 web_view_base_->SetVisualViewportOffset(initial_visual_viewport_offset_); |
| 265 // Background color override was already restored when | 266 // Background color override was already restored when |
| 266 // fullscreenElementChanged([..], nullptr) was called while exiting. | 267 // fullscreenElementChanged([..], nullptr) was called while exiting. |
| 267 | 268 |
| 268 state_ = State::kInitial; | 269 state_ = State::kInitial; |
| 270 web_view_base_->LayerTreeView()->SetIsFullscreen(false); | |
|
Khushal
2017/05/24 02:12:24
Why not do this in DidExitFullScreen?
steimel
2017/05/24 19:32:58
To me it seemed to make more sense that is_fullscr
Khushal
2017/05/25 03:33:40
The kNeedsScrollAndStateRestore is needed for chan
steimel
2017/06/06 03:07:53
Done.
| |
| 269 } | 271 } |
| 270 | 272 |
| 271 void FullscreenController::UpdatePageScaleConstraints(bool remove_constraints) { | 273 void FullscreenController::UpdatePageScaleConstraints(bool remove_constraints) { |
| 272 PageScaleConstraints fullscreen_constraints; | 274 PageScaleConstraints fullscreen_constraints; |
| 273 if (!remove_constraints) { | 275 if (!remove_constraints) { |
| 274 fullscreen_constraints = PageScaleConstraints(1.0, 1.0, 1.0); | 276 fullscreen_constraints = PageScaleConstraints(1.0, 1.0, 1.0); |
| 275 fullscreen_constraints.layout_size = FloatSize(web_view_base_->Size()); | 277 fullscreen_constraints.layout_size = FloatSize(web_view_base_->Size()); |
| 276 } | 278 } |
| 277 web_view_base_->GetPageScaleConstraintsSet().SetFullscreenConstraints( | 279 web_view_base_->GetPageScaleConstraintsSet().SetFullscreenConstraints( |
| 278 fullscreen_constraints); | 280 fullscreen_constraints); |
| 279 web_view_base_->GetPageScaleConstraintsSet().ComputeFinalConstraints(); | 281 web_view_base_->GetPageScaleConstraintsSet().ComputeFinalConstraints(); |
| 280 | 282 |
| 281 // Although we called |computedFinalConstraints()| above, the "final" | 283 // Although we called |computedFinalConstraints()| above, the "final" |
| 282 // constraints are not actually final. They are still subject to scale factor | 284 // constraints are not actually final. They are still subject to scale factor |
| 283 // clamping by contents size. Normally they should be dirtied due to contents | 285 // clamping by contents size. Normally they should be dirtied due to contents |
| 284 // size mutation after layout, however the contents size is not guaranteed to | 286 // size mutation after layout, however the contents size is not guaranteed to |
| 285 // mutate, and the scale factor may remain unclamped. Just fire the event | 287 // mutate, and the scale factor may remain unclamped. Just fire the event |
| 286 // again to ensure the final constraints pick up the latest contents size. | 288 // again to ensure the final constraints pick up the latest contents size. |
| 287 web_view_base_->DidChangeContentsSize(); | 289 web_view_base_->DidChangeContentsSize(); |
| 288 if (web_view_base_->MainFrameImpl() && | 290 if (web_view_base_->MainFrameImpl() && |
| 289 web_view_base_->MainFrameImpl()->GetFrameView()) | 291 web_view_base_->MainFrameImpl()->GetFrameView()) |
| 290 web_view_base_->MainFrameImpl()->GetFrameView()->SetNeedsLayout(); | 292 web_view_base_->MainFrameImpl()->GetFrameView()->SetNeedsLayout(); |
| 291 | 293 |
| 292 web_view_base_->UpdateMainFrameLayoutSize(); | 294 web_view_base_->UpdateMainFrameLayoutSize(); |
| 293 } | 295 } |
| 294 | 296 |
| 295 } // namespace blink | 297 } // namespace blink |
| OLD | NEW |