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

Unified Diff: third_party/WebKit/Source/core/dom/IntersectionObserver.cpp

Issue 2088963002: IntersectionObserver constructor: fail on invalid rootMargin syntax. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Simplify loop condition Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/intersection-observer/root-margin-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
diff --git a/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp b/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
index f67c1a9e27f5de3d64158bbcddb911508d6e4d5d..cdcbbcaa9302f5f403c66efe41d9a714e24aef78 100644
--- a/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
+++ b/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
@@ -39,11 +39,13 @@ static void parseRootMargin(String rootMarginParameter, Vector<Length>& rootMarg
// "1px 2px" = top/bottom left/right
// "1px 2px 3px" = top left/right bottom
// "1px 2px 3px 4px" = top left right bottom
- //
- // Any extra stuff after the first four tokens is ignored.
CSSTokenizer::Scope tokenizerScope(rootMarginParameter);
CSSParserTokenRange tokenRange = tokenizerScope.tokenRange();
- while (rootMargin.size() < 4 && tokenRange.peek().type() != EOFToken && !exceptionState.hadException()) {
+ while (tokenRange.peek().type() != EOFToken && !exceptionState.hadException()) {
+ if (rootMargin.size() == 4) {
+ exceptionState.throwDOMException(SyntaxError, "Extra text found at the end of rootMargin.");
+ break;
+ }
const CSSParserToken& token = tokenRange.consumeIncludingWhitespace();
switch (token.type()) {
case PercentageToken:
« no previous file with comments | « third_party/WebKit/LayoutTests/intersection-observer/root-margin-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698