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

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

Issue 69143002: Guard the rework of documentElement|body.scrollTop/Left under a runtime flag (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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) 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 Frame* frame = document->frame(); 198 Frame* frame = document->frame();
199 float zoomFactor = frame->pageZoomFactor(); 199 float zoomFactor = frame->pageZoomFactor();
200 if (zoomFactor == 1) 200 if (zoomFactor == 1)
201 return value; 201 return value;
202 // Needed because of truncation (rather than rounding) when scaling up. 202 // Needed because of truncation (rather than rounding) when scaling up.
203 if (zoomFactor > 1) 203 if (zoomFactor > 1)
204 value++; 204 value++;
205 return static_cast<int>(value / zoomFactor); 205 return static_cast<int>(value / zoomFactor);
206 } 206 }
207 207
208 // FIXME: There are cases where body.scrollLeft is allowed to return
209 // non-zero values in both quirks and strict mode. It happens when
210 // <body> has an overflow that is not the Frame overflow.
211 // http://dev.w3.org/csswg/cssom-view/#dom-element-scrollleft
212 // http://code.google.com/p/chromium/issues/detail?id=312435
208 int HTMLBodyElement::scrollLeft() 213 int HTMLBodyElement::scrollLeft()
209 { 214 {
210 Document& document = this->document(); 215 Document& document = this->document();
216 document.updateLayoutIgnorePendingStylesheets();
211 217
212 // FIXME: There are cases where body.scrollLeft is allowed to return 218 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
213 // non-zero values in both quirks and strict mode. It happens when 219 if (!document.inQuirksMode())
214 // <body> has an overflow that is not the Frame overflow. 220 return 0;
215 // http://dev.w3.org/csswg/cssom-view/#dom-element-scrollleft 221 }
216 if (!document.inQuirksMode())
217 UseCounter::countDeprecation(&document, UseCounter::ScrollLeftBodyNotQui rksMode);
218 222
219 document.updateLayoutIgnorePendingStylesheets();
220 FrameView* view = document.view(); 223 FrameView* view = document.view();
221 return view ? adjustForZoom(view->scrollX(), &document) : 0; 224 return view ? adjustForZoom(view->scrollX(), &document) : 0;
222 } 225 }
223 226
224 void HTMLBodyElement::setScrollLeft(int scrollLeft) 227 void HTMLBodyElement::setScrollLeft(int scrollLeft)
225 { 228 {
226 Document& document = this->document(); 229 Document& document = this->document();
230 document.updateLayoutIgnorePendingStylesheets();
227 231
228 if (!document.inQuirksMode()) 232 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
229 UseCounter::countDeprecation(&document, UseCounter::ScrollLeftBodyNotQui rksMode); 233 if (!document.inQuirksMode())
234 return;
235 }
230 236
231 document.updateLayoutIgnorePendingStylesheets();
232 Frame* frame = document.frame(); 237 Frame* frame = document.frame();
233 if (!frame) 238 if (!frame)
234 return; 239 return;
235 FrameView* view = frame->view(); 240 FrameView* view = frame->view();
236 if (!view) 241 if (!view)
237 return; 242 return;
238 view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZo omFactor()), view->scrollY())); 243 view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZo omFactor()), view->scrollY()));
239 } 244 }
240 245
241 int HTMLBodyElement::scrollTop() 246 int HTMLBodyElement::scrollTop()
242 { 247 {
243 Document& document = this->document(); 248 Document& document = this->document();
249 document.updateLayoutIgnorePendingStylesheets();
244 250
245 // FIXME: There are cases where body.scrollTop is allowed to return 251 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
246 // non-zero values in both quirks and strict mode. It happens when 252 if (!document.inQuirksMode())
247 // body has a overflow that is not the Frame overflow. 253 return 0;
248 // http://dev.w3.org/csswg/cssom-view/#dom-element-scrolltop 254 }
249 if (!document.inQuirksMode())
250 UseCounter::countDeprecation(&document, UseCounter::ScrollTopBodyNotQuir ksMode);
251 255
252 document.updateLayoutIgnorePendingStylesheets();
253 FrameView* view = document.view(); 256 FrameView* view = document.view();
254 return view ? adjustForZoom(view->scrollY(), &document) : 0; 257 return view ? adjustForZoom(view->scrollY(), &document) : 0;
255 } 258 }
256 259
257 void HTMLBodyElement::setScrollTop(int scrollTop) 260 void HTMLBodyElement::setScrollTop(int scrollTop)
258 { 261 {
259 Document& document = this->document(); 262 Document& document = this->document();
263 document.updateLayoutIgnorePendingStylesheets();
260 264
261 if (!document.inQuirksMode()) 265 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
262 UseCounter::countDeprecation(&document, UseCounter::ScrollTopBodyNotQuir ksMode); 266 if (!document.inQuirksMode())
267 return;
268 }
263 269
264 document.updateLayoutIgnorePendingStylesheets();
265 Frame* frame = document.frame(); 270 Frame* frame = document.frame();
266 if (!frame) 271 if (!frame)
267 return; 272 return;
268 FrameView* view = frame->view(); 273 FrameView* view = frame->view();
269 if (!view) 274 if (!view)
270 return; 275 return;
271 view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * frame->pageZoomFactor()))); 276 view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * frame->pageZoomFactor())));
272 } 277 }
273 278
274 int HTMLBodyElement::scrollHeight() 279 int HTMLBodyElement::scrollHeight()
(...skipping 15 matching lines...) Expand all
290 } 295 }
291 296
292 void HTMLBodyElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const 297 void HTMLBodyElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
293 { 298 {
294 HTMLElement::addSubresourceAttributeURLs(urls); 299 HTMLElement::addSubresourceAttributeURLs(urls);
295 300
296 addSubresourceURL(urls, document().completeURL(getAttribute(backgroundAttr)) ); 301 addSubresourceURL(urls, document().completeURL(getAttribute(backgroundAttr)) );
297 } 302 }
298 303
299 } // namespace WebCore 304 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698