Index: Source/core/dom/Element.cpp |
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp |
index 8d66bf56ac612848c00ed8aacdaeb08b4072e4dd..a6da13e77e2c079cc53e6ff85eaf015675ba7131 100644 |
--- a/Source/core/dom/Element.cpp |
+++ b/Source/core/dom/Element.cpp |
@@ -721,36 +721,41 @@ int Element::scrollTop() |
return 0; |
} |
-void Element::setScrollLeft(int newLeft) |
+void Element::setScrollLeft(int newLeft, ScrollBehavior scrollBehavior) |
{ |
- document().updateLayoutIgnorePendingStylesheets(); |
+ setScrollLeftInternal(newLeft, scrollBehavior); |
+} |
- if (document().documentElement() != this) { |
- if (RenderBox* rend = renderBox()) |
- rend->setScrollLeft(static_cast<int>(newLeft * rend->style()->effectiveZoom())); |
- return; |
+void Element::setScrollLeft(const Dictionary& scrollOptionsHorizontal, ExceptionState& exceptionState) |
+{ |
+ String scrollBehaviorString; |
+ ScrollBehavior scrollBehavior = ScrollBehaviorAuto; |
+ if (scrollOptionsHorizontal.get("behavior", scrollBehaviorString)) { |
+ if (!ScrollableArea::scrollBehaviorFromString(scrollBehaviorString, scrollBehavior)) { |
+ exceptionState.throwTypeError("The ScrollBehavior provided is invalid."); |
+ return; |
+ } |
} |
- if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
- if (document().inQuirksMode()) |
- return; |
+ int position; |
+ if (!scrollOptionsHorizontal.get("x", position)) { |
+ exceptionState.throwTypeError("ScrollOptionsHorizontal must include an 'x' member."); |
+ return; |
+ } |
- Frame* frame = document().frame(); |
- if (!frame) |
- return; |
- FrameView* view = frame->view(); |
- if (!view) |
- return; |
+ setScrollLeft(position, scrollBehavior); |
+} |
- view->setScrollPosition(IntPoint(static_cast<int>(newLeft * frame->pageZoomFactor()), view->scrollY())); |
- } |
+void Element::setScrollTop(int newTop, ScrollBehavior scrollBehavior) |
+{ |
+ setScrollTopInternal(newTop, scrollBehavior); |
} |
-void Element::setScrollLeft(const Dictionary& scrollOptionsHorizontal, ExceptionState& exceptionState) |
+void Element::setScrollTop(const Dictionary& scrollOptionsVertical, ExceptionState& exceptionState) |
{ |
String scrollBehaviorString; |
ScrollBehavior scrollBehavior = ScrollBehaviorAuto; |
- if (scrollOptionsHorizontal.get("behavior", scrollBehaviorString)) { |
+ if (scrollOptionsVertical.get("behavior", scrollBehaviorString)) { |
if (!ScrollableArea::scrollBehaviorFromString(scrollBehaviorString, scrollBehavior)) { |
exceptionState.throwTypeError("The ScrollBehavior provided is invalid."); |
Ian Vollick
2014/02/06 16:02:31
Do you have tests that try setting a bad behavior
|
return; |
@@ -758,22 +763,21 @@ void Element::setScrollLeft(const Dictionary& scrollOptionsHorizontal, Exception |
} |
int position; |
- if (!scrollOptionsHorizontal.get("x", position)) { |
- exceptionState.throwTypeError("ScrollOptionsHorizontal must include an 'x' member."); |
+ if (!scrollOptionsVertical.get("y", position)) { |
+ exceptionState.throwTypeError("ScrollOptionsVertical must include a 'y' member."); |
return; |
} |
- // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instantly. |
- setScrollLeft(position); |
+ setScrollTop(position, scrollBehavior); |
} |
-void Element::setScrollTop(int newTop) |
+void Element::setScrollLeftInternal(int newLeft, ScrollBehavior scrollBehavior) |
{ |
document().updateLayoutIgnorePendingStylesheets(); |
if (document().documentElement() != this) { |
if (RenderBox* rend = renderBox()) |
- rend->setScrollTop(static_cast<int>(newTop * rend->style()->effectiveZoom())); |
+ rend->setScrollLeft(static_cast<int>(newLeft * rend->style()->effectiveZoom()), scrollBehavior); |
return; |
} |
@@ -788,29 +792,33 @@ void Element::setScrollTop(int newTop) |
if (!view) |
return; |
- view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(newTop * frame->pageZoomFactor()))); |
+ view->setScrollPosition(IntPoint(static_cast<int>(newLeft * frame->pageZoomFactor()), view->scrollY()), scrollBehavior); |
} |
} |
-void Element::setScrollTop(const Dictionary& scrollOptionsVertical, ExceptionState& exceptionState) |
+void Element::setScrollTopInternal(int newTop, ScrollBehavior scrollBehavior) |
{ |
- String scrollBehaviorString; |
- ScrollBehavior scrollBehavior = ScrollBehaviorAuto; |
- if (scrollOptionsVertical.get("behavior", scrollBehaviorString)) { |
- if (!ScrollableArea::scrollBehaviorFromString(scrollBehaviorString, scrollBehavior)) { |
- exceptionState.throwTypeError("The ScrollBehavior provided is invalid."); |
- return; |
- } |
- } |
+ document().updateLayoutIgnorePendingStylesheets(); |
- int position; |
- if (!scrollOptionsVertical.get("y", position)) { |
- exceptionState.throwTypeError("ScrollOptionsVertical must include a 'y' member."); |
+ if (document().documentElement() != this) { |
+ if (RenderBox* rend = renderBox()) |
+ rend->setScrollTop(static_cast<int>(newTop * rend->style()->effectiveZoom()), scrollBehavior); |
return; |
} |
- // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instantly. |
- setScrollTop(position); |
+ if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
+ if (document().inQuirksMode()) |
+ return; |
+ |
+ Frame* frame = document().frame(); |
+ if (!frame) |
+ return; |
+ FrameView* view = frame->view(); |
+ if (!view) |
+ return; |
+ |
+ view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(newTop * frame->pageZoomFactor())), scrollBehavior); |
+ } |
} |
int Element::scrollWidth() |