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

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

Issue 26489005: Relax HTMLBodyElement's scrollTop/Left property set and get operations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@issue_290895
Patch Set: Relax HTMLBodyElement's scrollTop/Left property set and get operations. Created 7 years, 2 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
« no previous file with comments | « LayoutTests/jquery/offset-expected.txt ('k') | Source/core/page/UseCounter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (zoomFactor == 1) 246 if (zoomFactor == 1)
247 return value; 247 return value;
248 // Needed because of truncation (rather than rounding) when scaling up. 248 // Needed because of truncation (rather than rounding) when scaling up.
249 if (zoomFactor > 1) 249 if (zoomFactor > 1)
250 value++; 250 value++;
251 return static_cast<int>(value / zoomFactor); 251 return static_cast<int>(value / zoomFactor);
252 } 252 }
253 253
254 int HTMLBodyElement::scrollLeft() 254 int HTMLBodyElement::scrollLeft()
255 { 255 {
256 Document& document = this->document();
257
256 // FIXME: The specification is not clear about what is the expected behavior here: 258 // FIXME: The specification is not clear about what is the expected behavior here:
257 // http://dev.w3.org/csswg/cssom-view/#dom-element-scrollleft 259 // http://dev.w3.org/csswg/cssom-view/#dom-element-scrollleft
258 // Blink bails out in order to match other engines' behavior (WebKit, IE, Fi refox and Opera12). 260 // Blink bails out in order to match other engines' behavior (WebKit, IE, Fi refox and Opera12).
259 if (!document().inQuirksMode()) 261 if (!document.inQuirksMode())
260 return 0; 262 UseCounter::countDeprecation(&document, UseCounter::ScrollLeftBody);
263 else
264 UseCounter::count(&document, UseCounter::ScrollLeftBody);
261 265
262 // Update the document's layout.
263 Document& document = this->document();
264 document.updateLayoutIgnorePendingStylesheets(); 266 document.updateLayoutIgnorePendingStylesheets();
265 FrameView* view = document.view(); 267 FrameView* view = document.view();
266 return view ? adjustForZoom(view->scrollX(), &document) : 0; 268 return view ? adjustForZoom(view->scrollX(), &document) : 0;
267 } 269 }
268 270
269 void HTMLBodyElement::setScrollLeft(int scrollLeft) 271 void HTMLBodyElement::setScrollLeft(int scrollLeft)
270 { 272 {
271 if (!document().inQuirksMode()) 273 Document& document = this->document();
272 return;
273 274
274 Document& document = this->document(); 275 if (!document.inQuirksMode())
276 UseCounter::countDeprecation(&document, UseCounter::ScrollLeftBody);
277 else
278 UseCounter::count(&document, UseCounter::ScrollLeftBody);
279
275 document.updateLayoutIgnorePendingStylesheets(); 280 document.updateLayoutIgnorePendingStylesheets();
276 Frame* frame = document.frame(); 281 Frame* frame = document.frame();
277 if (!frame) 282 if (!frame)
278 return; 283 return;
279 FrameView* view = frame->view(); 284 FrameView* view = frame->view();
280 if (!view) 285 if (!view)
281 return; 286 return;
282 view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZo omFactor()), view->scrollY())); 287 view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZo omFactor()), view->scrollY()));
283 } 288 }
284 289
285 int HTMLBodyElement::scrollTop() 290 int HTMLBodyElement::scrollTop()
286 { 291 {
292 Document& document = this->document();
293
287 // FIXME: The specification is not clear about what is the expected behavior here: 294 // FIXME: The specification is not clear about what is the expected behavior here:
288 // http://dev.w3.org/csswg/cssom-view/#dom-element-scrolltop . 295 // http://dev.w3.org/csswg/cssom-view/#dom-element-scrolltop .
289 // Blink bails out in order to match other engines' behavior (WebKit, IE, Fi refox and Opera12). 296 // Blink should bail out in order to match other engines' behavior (WebKit, IE, Firefox and Opera12).
290 if (!document().inQuirksMode()) 297 if (!document.inQuirksMode())
291 return 0; 298 UseCounter::countDeprecation(&document, UseCounter::ScrollTopBody);
299 else
300 UseCounter::count(&document, UseCounter::ScrollTopBody);
292 301
293 // Update the document's layout.
294 Document& document = this->document();
295 document.updateLayoutIgnorePendingStylesheets(); 302 document.updateLayoutIgnorePendingStylesheets();
296 FrameView* view = document.view(); 303 FrameView* view = document.view();
297 return view ? adjustForZoom(view->scrollY(), &document) : 0; 304 return view ? adjustForZoom(view->scrollY(), &document) : 0;
298 } 305 }
299 306
300 void HTMLBodyElement::setScrollTop(int scrollTop) 307 void HTMLBodyElement::setScrollTop(int scrollTop)
301 { 308 {
302 if (!document().inQuirksMode()) 309 Document& document = this->document();
303 return;
304 310
305 Document& document = this->document(); 311 if (!document.inQuirksMode())
312 UseCounter::countDeprecation(&document, UseCounter::ScrollTopBody);
313 else
314 UseCounter::count(&document, UseCounter::ScrollTopBody);
315
306 document.updateLayoutIgnorePendingStylesheets(); 316 document.updateLayoutIgnorePendingStylesheets();
307 Frame* frame = document.frame(); 317 Frame* frame = document.frame();
308 if (!frame) 318 if (!frame)
309 return; 319 return;
310 FrameView* view = frame->view(); 320 FrameView* view = frame->view();
311 if (!view) 321 if (!view)
312 return; 322 return;
313 view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * frame->pageZoomFactor()))); 323 view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * frame->pageZoomFactor())));
314 } 324 }
315 325
(...skipping 16 matching lines...) Expand all
332 } 342 }
333 343
334 void HTMLBodyElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const 344 void HTMLBodyElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
335 { 345 {
336 HTMLElement::addSubresourceAttributeURLs(urls); 346 HTMLElement::addSubresourceAttributeURLs(urls);
337 347
338 addSubresourceURL(urls, document().completeURL(getAttribute(backgroundAttr)) ); 348 addSubresourceURL(urls, document().completeURL(getAttribute(backgroundAttr)) );
339 } 349 }
340 350
341 } // namespace WebCore 351 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/jquery/offset-expected.txt ('k') | Source/core/page/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698