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

Side by Side Diff: Source/core/html/HTMLBodyElement.cpp

Issue 134443003: Implement CSSOM Smooth Scroll API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Simon Hausmann (hausmann@kde.org) 4 * (C) 2000 Simon Hausmann (hausmann@kde.org)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 if (render->hasOverflowClip()) 221 if (render->hasOverflowClip())
222 return adjustForAbsoluteZoom(render->scrollLeft(), render); 222 return adjustForAbsoluteZoom(render->scrollLeft(), render);
223 if (!document.inQuirksMode()) 223 if (!document.inQuirksMode())
224 return 0; 224 return 0;
225 } 225 }
226 226
227 FrameView* view = document.view(); 227 FrameView* view = document.view();
228 return view ? adjustForZoom(view->scrollX(), &document) : 0; 228 return view ? adjustForZoom(view->scrollX(), &document) : 0;
229 } 229 }
230 230
231 void HTMLBodyElement::setScrollLeft(int scrollLeft) 231 void HTMLBodyElement::setScrollLeftInternal(int scrollLeft, ScrollBehavior scrol lBehavior)
232 { 232 {
233 Document& document = this->document(); 233 Document& document = this->document();
234 document.updateLayoutIgnorePendingStylesheets(); 234 document.updateLayoutIgnorePendingStylesheets();
235 235
236 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { 236 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
237 RenderBox* render = renderBox(); 237 RenderBox* render = renderBox();
238 if (!render) 238 if (!render)
239 return; 239 return;
240 if (render->hasOverflowClip()) { 240 if (render->hasOverflowClip()) {
241 // FIXME: Investigate how are other browsers casting to int (roundin g, ceiling, ...). 241 // FIXME: Investigate how are other browsers casting to int (roundin g, ceiling, ...).
242 render->setScrollLeft(static_cast<int>(scrollLeft * render->style()- >effectiveZoom())); 242 render->setScrollLeft(static_cast<int>(scrollLeft * render->style()- >effectiveZoom()), scrollBehavior);
243 return; 243 return;
244 } 244 }
245 if (!document.inQuirksMode()) 245 if (!document.inQuirksMode())
246 return; 246 return;
247 } 247 }
248 248
249 Frame* frame = document.frame(); 249 Frame* frame = document.frame();
250 if (!frame) 250 if (!frame)
251 return; 251 return;
252 FrameView* view = frame->view(); 252 FrameView* view = frame->view();
253 if (!view) 253 if (!view)
254 return; 254 return;
255 view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZo omFactor()), view->scrollY())); 255 view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZo omFactor()), view->scrollY()), scrollBehavior);
256 } 256 }
257 257
258 int HTMLBodyElement::scrollTop() 258 int HTMLBodyElement::scrollTop()
259 { 259 {
260 Document& document = this->document(); 260 Document& document = this->document();
261 document.updateLayoutIgnorePendingStylesheets(); 261 document.updateLayoutIgnorePendingStylesheets();
262 262
263 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { 263 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
264 RenderBox* render = renderBox(); 264 RenderBox* render = renderBox();
265 if (!render) 265 if (!render)
266 return 0; 266 return 0;
267 if (render->hasOverflowClip()) 267 if (render->hasOverflowClip())
268 return adjustForAbsoluteZoom(render->scrollTop(), render); 268 return adjustForAbsoluteZoom(render->scrollTop(), render);
269 if (!document.inQuirksMode()) 269 if (!document.inQuirksMode())
270 return 0; 270 return 0;
271 } 271 }
272 272
273 FrameView* view = document.view(); 273 FrameView* view = document.view();
274 return view ? adjustForZoom(view->scrollY(), &document) : 0; 274 return view ? adjustForZoom(view->scrollY(), &document) : 0;
275 } 275 }
276 276
277 void HTMLBodyElement::setScrollTop(int scrollTop) 277 void HTMLBodyElement::setScrollTopInternal(int scrollTop, ScrollBehavior scrollB ehavior)
278 { 278 {
279 Document& document = this->document(); 279 Document& document = this->document();
280 document.updateLayoutIgnorePendingStylesheets(); 280 document.updateLayoutIgnorePendingStylesheets();
281 281
282 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { 282 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
283 RenderBox* render = renderBox(); 283 RenderBox* render = renderBox();
284 if (!render) 284 if (!render)
285 return; 285 return;
286 if (render->hasOverflowClip()) { 286 if (render->hasOverflowClip()) {
287 // FIXME: Investigate how are other browsers casting to int (roundin g, ceiling, ...). 287 // FIXME: Investigate how are other browsers casting to int (roundin g, ceiling, ...).
288 render->setScrollTop(static_cast<int>(scrollTop * render->style()->e ffectiveZoom())); 288 render->setScrollTop(static_cast<int>(scrollTop * render->style()->e ffectiveZoom()), scrollBehavior);
289 return; 289 return;
290 } 290 }
291 if (!document.inQuirksMode()) 291 if (!document.inQuirksMode())
292 return; 292 return;
293 } 293 }
294 294
295 Frame* frame = document.frame(); 295 Frame* frame = document.frame();
296 if (!frame) 296 if (!frame)
297 return; 297 return;
298 FrameView* view = frame->view(); 298 FrameView* view = frame->view();
299 if (!view) 299 if (!view)
300 return; 300 return;
301 view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * frame->pageZoomFactor()))); 301 view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * frame->pageZoomFactor())), scrollBehavior);
302 } 302 }
303 303
304 int HTMLBodyElement::scrollHeight() 304 int HTMLBodyElement::scrollHeight()
305 { 305 {
306 // Update the document's layout. 306 // Update the document's layout.
307 Document& document = this->document(); 307 Document& document = this->document();
308 document.updateLayoutIgnorePendingStylesheets(); 308 document.updateLayoutIgnorePendingStylesheets();
309 FrameView* view = document.view(); 309 FrameView* view = document.view();
310 return view ? adjustForZoom(view->contentsHeight(), &document) : 0; 310 return view ? adjustForZoom(view->contentsHeight(), &document) : 0;
311 } 311 }
312 312
313 int HTMLBodyElement::scrollWidth() 313 int HTMLBodyElement::scrollWidth()
314 { 314 {
315 // Update the document's layout. 315 // Update the document's layout.
316 Document& document = this->document(); 316 Document& document = this->document();
317 document.updateLayoutIgnorePendingStylesheets(); 317 document.updateLayoutIgnorePendingStylesheets();
318 FrameView* view = document.view(); 318 FrameView* view = document.view();
319 return view ? adjustForZoom(view->contentsWidth(), &document) : 0; 319 return view ? adjustForZoom(view->contentsWidth(), &document) : 0;
320 } 320 }
321 321
322 } // namespace WebCore 322 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698