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

Side by Side Diff: Source/core/frame/LocalDOMWindow.cpp

Issue 670833002: Early out if the scroll position passed in by js is NaN (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: address comments Created 6 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 | « Source/core/dom/Element.cpp ('k') | Source/core/html/HTMLBodyElement.cpp » ('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) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 { 1373 {
1374 if (!isCurrentlyDisplayedInFrame()) 1374 if (!isCurrentlyDisplayedInFrame())
1375 return; 1375 return;
1376 1376
1377 document()->updateLayoutIgnorePendingStylesheets(); 1377 document()->updateLayoutIgnorePendingStylesheets();
1378 1378
1379 FrameView* view = m_frame->view(); 1379 FrameView* view = m_frame->view();
1380 if (!view) 1380 if (!view)
1381 return; 1381 return;
1382 1382
1383 if (std::isnan(x) || std::isnan(y))
1384 return;
1385
1383 DoubleSize scaledOffset(x * m_frame->pageZoomFactor(), y * m_frame->pageZoom Factor()); 1386 DoubleSize scaledOffset(x * m_frame->pageZoomFactor(), y * m_frame->pageZoom Factor());
1384 view->scrollBy(scaledOffset, scrollBehavior); 1387 view->scrollBy(scaledOffset, scrollBehavior);
1385 } 1388 }
1386 1389
1387 void LocalDOMWindow::scrollBy(double x, double y, const ScrollOptions& scrollOpt ions, ExceptionState &exceptionState) const 1390 void LocalDOMWindow::scrollBy(double x, double y, const ScrollOptions& scrollOpt ions, ExceptionState &exceptionState) const
1388 { 1391 {
1389 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; 1392 ScrollBehavior scrollBehavior = ScrollBehaviorAuto;
1390 if (!scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptio nState)) 1393 if (!scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptio nState))
1391 return; 1394 return;
1392 scrollBy(x, y, scrollBehavior); 1395 scrollBy(x, y, scrollBehavior);
1393 } 1396 }
1394 1397
1395 void LocalDOMWindow::scrollTo(double x, double y, ScrollBehavior scrollBehavior) const 1398 void LocalDOMWindow::scrollTo(double x, double y, ScrollBehavior scrollBehavior) const
1396 { 1399 {
1397 if (!isCurrentlyDisplayedInFrame()) 1400 if (!isCurrentlyDisplayedInFrame())
1398 return; 1401 return;
1399 1402
1400 document()->updateLayoutIgnorePendingStylesheets(); 1403 document()->updateLayoutIgnorePendingStylesheets();
1401 1404
1402 RefPtrWillBeRawPtr<FrameView> view = m_frame->view(); 1405 RefPtrWillBeRawPtr<FrameView> view = m_frame->view();
1403 if (!view) 1406 if (!view)
1404 return; 1407 return;
1405 1408
1409 if (std::isnan(x) || std::isnan(y))
1410 return;
1411
1406 DoublePoint layoutPos(x * m_frame->pageZoomFactor(), y * m_frame->pageZoomFa ctor()); 1412 DoublePoint layoutPos(x * m_frame->pageZoomFactor(), y * m_frame->pageZoomFa ctor());
1407 view->setScrollPosition(layoutPos, scrollBehavior); 1413 view->setScrollPosition(layoutPos, scrollBehavior);
1408 } 1414 }
1409 1415
1410 void LocalDOMWindow::scrollTo(double x, double y, const ScrollOptions& scrollOpt ions, ExceptionState& exceptionState) const 1416 void LocalDOMWindow::scrollTo(double x, double y, const ScrollOptions& scrollOpt ions, ExceptionState& exceptionState) const
1411 { 1417 {
1412 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; 1418 ScrollBehavior scrollBehavior = ScrollBehaviorAuto;
1413 if (!scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptio nState)) 1419 if (!scrollBehaviorFromScrollOptions(scrollOptions, scrollBehavior, exceptio nState))
1414 return; 1420 return;
1415 scrollTo(x, y, scrollBehavior); 1421 scrollTo(x, y, scrollBehavior);
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 FrameDestructionObserver::trace(visitor); 1925 FrameDestructionObserver::trace(visitor);
1920 } 1926 }
1921 1927
1922 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate) 1928 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate)
1923 { 1929 {
1924 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. 1930 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8].
1925 return v8::Handle<v8::Object>(); 1931 return v8::Handle<v8::Object>();
1926 } 1932 }
1927 1933
1928 } // namespace blink 1934 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/core/html/HTMLBodyElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698