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

Side by Side Diff: third_party/WebKit/Source/core/frame/FullscreenController.cpp

Issue 2936423003: Move Get/SetScrollOffset methods from WebFrame to WebLocalFrame. (Closed)
Patch Set: Use WebViewHelper::LocalMainFrame() where possible. Created 3 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 unified diff | Download patch
OLDNEW
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
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());
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 // We need to store these values here rather than in |DidEnterFullscreen()| 147 // We need to store these values here rather than in |DidEnterFullscreen()|
148 // since by the time the latter is called, a Resize has already occured, 148 // since by the time the latter is called, a Resize has already occured,
149 // clamping the scroll offset. Don't save values if we're still waiting to 149 // clamping the scroll offset. Don't save values if we're still waiting to
150 // restore a previous set. This can happen if we exit and quickly reenter 150 // restore a previous set. This can happen if we exit and quickly reenter
151 // fullscreen without performing a layout. 151 // fullscreen without performing a layout.
152 if (state_ == State::kInitial) { 152 if (state_ == State::kInitial) {
153 initial_page_scale_factor_ = web_view_base_->PageScaleFactor(); 153 initial_page_scale_factor_ = web_view_base_->PageScaleFactor();
154 initial_scroll_offset_ = 154 initial_scroll_offset_ =
155 web_view_base_->MainFrame()->IsWebLocalFrame() 155 web_view_base_->MainFrame()->IsWebLocalFrame()
156 ? web_view_base_->MainFrame()->GetScrollOffset() 156 ? web_view_base_->MainFrame()->ToWebLocalFrame()->GetScrollOffset()
157 : WebSize(); 157 : WebSize();
158 initial_visual_viewport_offset_ = web_view_base_->VisualViewportOffset(); 158 initial_visual_viewport_offset_ = web_view_base_->VisualViewportOffset();
159 initial_background_color_override_enabled_ = 159 initial_background_color_override_enabled_ =
160 web_view_base_->BackgroundColorOverrideEnabled(); 160 web_view_base_->BackgroundColorOverrideEnabled();
161 initial_background_color_override_ = 161 initial_background_color_override_ =
162 web_view_base_->BackgroundColorOverride(); 162 web_view_base_->BackgroundColorOverride();
163 } 163 }
164 164
165 // If already entering fullscreen, just wait. 165 // If already entering fullscreen, just wait.
166 if (state_ == State::kEnteringFullscreen) 166 if (state_ == State::kEnteringFullscreen)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 254 }
255 } 255 }
256 } 256 }
257 257
258 void FullscreenController::DidUpdateLayout() { 258 void FullscreenController::DidUpdateLayout() {
259 if (state_ != State::kNeedsScrollAndScaleRestore) 259 if (state_ != State::kNeedsScrollAndScaleRestore)
260 return; 260 return;
261 261
262 web_view_base_->SetPageScaleFactor(initial_page_scale_factor_); 262 web_view_base_->SetPageScaleFactor(initial_page_scale_factor_);
263 if (web_view_base_->MainFrame()->IsWebLocalFrame()) { 263 if (web_view_base_->MainFrame()->IsWebLocalFrame()) {
264 web_view_base_->MainFrame()->SetScrollOffset( 264 web_view_base_->MainFrame()->ToWebLocalFrame()->SetScrollOffset(
265 WebSize(initial_scroll_offset_)); 265 WebSize(initial_scroll_offset_));
266 } 266 }
267 web_view_base_->SetVisualViewportOffset(initial_visual_viewport_offset_); 267 web_view_base_->SetVisualViewportOffset(initial_visual_viewport_offset_);
268 // Background color override was already restored when 268 // Background color override was already restored when
269 // FullscreenElementChanged([..], nullptr) was called while exiting. 269 // FullscreenElementChanged([..], nullptr) was called while exiting.
270 270
271 state_ = State::kInitial; 271 state_ = State::kInitial;
272 } 272 }
273 273
274 void FullscreenController::UpdatePageScaleConstraints(bool remove_constraints) { 274 void FullscreenController::UpdatePageScaleConstraints(bool remove_constraints) {
(...skipping 14 matching lines...) Expand all
289 // again to ensure the final constraints pick up the latest contents size. 289 // again to ensure the final constraints pick up the latest contents size.
290 web_view_base_->DidChangeContentsSize(); 290 web_view_base_->DidChangeContentsSize();
291 if (web_view_base_->MainFrameImpl() && 291 if (web_view_base_->MainFrameImpl() &&
292 web_view_base_->MainFrameImpl()->GetFrameView()) 292 web_view_base_->MainFrameImpl()->GetFrameView())
293 web_view_base_->MainFrameImpl()->GetFrameView()->SetNeedsLayout(); 293 web_view_base_->MainFrameImpl()->GetFrameView()->SetNeedsLayout();
294 294
295 web_view_base_->UpdateMainFrameLayoutSize(); 295 web_view_base_->UpdateMainFrameLayoutSize();
296 } 296 }
297 297
298 } // namespace blink 298 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698