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

Side by Side Diff: Source/core/dom/Element.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
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) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 654
655 if (FrameView* view = document().view()) { 655 if (FrameView* view = document().view()) {
656 if (RenderView* renderView = document().renderView()) 656 if (RenderView* renderView = document().renderView())
657 return adjustScrollForAbsoluteZoom(view->scrollY(), *renderView) ; 657 return adjustScrollForAbsoluteZoom(view->scrollY(), *renderView) ;
658 } 658 }
659 } 659 }
660 660
661 return 0; 661 return 0;
662 } 662 }
663 663
664 void Element::setScrollLeft(double newLeft) 664 void Element::setScrollLeft(double newLeft)
Rick Byers 2014/10/22 13:55:33 Sorry, should have mentioned this earlier: setScro
Yufeng Shen (Slow to review) 2014/10/22 17:38:46 Done.
665 { 665 {
666 document().updateLayoutIgnorePendingStylesheets(); 666 document().updateLayoutIgnorePendingStylesheets();
667 667
668 if (std::isnan(newLeft))
669 return;
670
668 if (document().documentElement() != this) { 671 if (document().documentElement() != this) {
669 RenderBox* rend = renderBox(); 672 RenderBox* rend = renderBox();
670 if (rend && !std::isnan(newLeft)) 673 if (rend)
671 rend->setScrollLeft(LayoutUnit::fromFloatRound(newLeft * rend->style ()->effectiveZoom())); 674 rend->setScrollLeft(LayoutUnit::fromFloatRound(newLeft * rend->style ()->effectiveZoom()));
672 return; 675 return;
673 } 676 }
674 677
675 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { 678 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
676 if (document().inQuirksMode()) 679 if (document().inQuirksMode())
677 return; 680 return;
678 681
679 LocalFrame* frame = document().frame(); 682 LocalFrame* frame = document().frame();
680 if (!frame) 683 if (!frame)
(...skipping 24 matching lines...) Expand all
705 } 708 }
706 709
707 // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instant ly. 710 // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instant ly.
708 setScrollLeft(position); 711 setScrollLeft(position);
709 } 712 }
710 713
711 void Element::setScrollTop(double newTop) 714 void Element::setScrollTop(double newTop)
712 { 715 {
713 document().updateLayoutIgnorePendingStylesheets(); 716 document().updateLayoutIgnorePendingStylesheets();
714 717
718 if (std::isnan(newTop))
719 return;
720
715 if (document().documentElement() != this) { 721 if (document().documentElement() != this) {
716 RenderBox* rend = renderBox(); 722 RenderBox* rend = renderBox();
717 if (rend && !std::isnan(newTop)) 723 if (rend)
718 rend->setScrollTop(LayoutUnit::fromFloatRound(newTop * rend->style() ->effectiveZoom())); 724 rend->setScrollTop(LayoutUnit::fromFloatRound(newTop * rend->style() ->effectiveZoom()));
719 return; 725 return;
720 } 726 }
721 727
722 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { 728 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
723 if (document().inQuirksMode()) 729 if (document().inQuirksMode())
724 return; 730 return;
725 731
726 LocalFrame* frame = document().frame(); 732 LocalFrame* frame = document().frame();
727 if (!frame) 733 if (!frame)
(...skipping 2580 matching lines...) Expand 10 before | Expand all | Expand 10 after
3308 return wrapper; 3314 return wrapper;
3309 3315
3310 CustomElementBinding* binding = perContextData->customElementBinding(customE lementDefinition()); 3316 CustomElementBinding* binding = perContextData->customElementBinding(customE lementDefinition());
3311 3317
3312 wrapper->SetPrototype(binding->prototype()); 3318 wrapper->SetPrototype(binding->prototype());
3313 3319
3314 return V8DOMWrapper::associateObjectWithWrapperNonTemplate(this, wrapperType , wrapper, isolate); 3320 return V8DOMWrapper::associateObjectWithWrapperNonTemplate(this, wrapperType , wrapper, isolate);
3315 } 3321 }
3316 3322
3317 } // namespace blink 3323 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698