| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/dom/IntersectionObserver.h" | 5 #include "core/dom/IntersectionObserver.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "core/css/parser/CSSParserTokenRange.h" | 8 #include "core/css/parser/CSSParserTokenRange.h" |
| 9 #include "core/css/parser/CSSTokenizer.h" | 9 #include "core/css/parser/CSSTokenizer.h" |
| 10 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 static void parseRootMargin(String rootMarginParameter, Vector<Length>& rootMarg
in, ExceptionState& exceptionState) | 32 static void parseRootMargin(String rootMarginParameter, Vector<Length>& rootMarg
in, ExceptionState& exceptionState) |
| 33 { | 33 { |
| 34 // TODO(szager): Make sure this exact syntax and behavior is spec-ed somewhe
re. | 34 // TODO(szager): Make sure this exact syntax and behavior is spec-ed somewhe
re. |
| 35 | 35 |
| 36 // The root margin argument accepts syntax similar to that for CSS margin: | 36 // The root margin argument accepts syntax similar to that for CSS margin: |
| 37 // | 37 // |
| 38 // "1px" = top/right/bottom/left | 38 // "1px" = top/right/bottom/left |
| 39 // "1px 2px" = top/bottom left/right | 39 // "1px 2px" = top/bottom left/right |
| 40 // "1px 2px 3px" = top left/right bottom | 40 // "1px 2px 3px" = top left/right bottom |
| 41 // "1px 2px 3px 4px" = top left right bottom | 41 // "1px 2px 3px 4px" = top left right bottom |
| 42 // | |
| 43 // Any extra stuff after the first four tokens is ignored. | |
| 44 CSSTokenizer::Scope tokenizerScope(rootMarginParameter); | 42 CSSTokenizer::Scope tokenizerScope(rootMarginParameter); |
| 45 CSSParserTokenRange tokenRange = tokenizerScope.tokenRange(); | 43 CSSParserTokenRange tokenRange = tokenizerScope.tokenRange(); |
| 46 while (rootMargin.size() < 4 && tokenRange.peek().type() != EOFToken && !exc
eptionState.hadException()) { | 44 while (tokenRange.peek().type() != EOFToken && !exceptionState.hadException(
)) { |
| 45 if (rootMargin.size() == 4) { |
| 46 exceptionState.throwDOMException(SyntaxError, "Extra text found at t
he end of rootMargin."); |
| 47 break; |
| 48 } |
| 47 const CSSParserToken& token = tokenRange.consumeIncludingWhitespace(); | 49 const CSSParserToken& token = tokenRange.consumeIncludingWhitespace(); |
| 48 switch (token.type()) { | 50 switch (token.type()) { |
| 49 case PercentageToken: | 51 case PercentageToken: |
| 50 rootMargin.append(Length(token.numericValue(), Percent)); | 52 rootMargin.append(Length(token.numericValue(), Percent)); |
| 51 break; | 53 break; |
| 52 case DimensionToken: | 54 case DimensionToken: |
| 53 switch (token.unitType()) { | 55 switch (token.unitType()) { |
| 54 case CSSPrimitiveValue::UnitType::Pixels: | 56 case CSSPrimitiveValue::UnitType::Pixels: |
| 55 rootMargin.append(Length(static_cast<int>(floor(token.numericVal
ue())), Fixed)); | 57 rootMargin.append(Length(static_cast<int>(floor(token.numericVal
ue())), Fixed)); |
| 56 break; | 58 break; |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 354 |
| 353 DEFINE_TRACE(IntersectionObserver) | 355 DEFINE_TRACE(IntersectionObserver) |
| 354 { | 356 { |
| 355 visitor->template registerWeakMembers<IntersectionObserver, &IntersectionObs
erver::clearWeakMembers>(this); | 357 visitor->template registerWeakMembers<IntersectionObserver, &IntersectionObs
erver::clearWeakMembers>(this); |
| 356 visitor->trace(m_callback); | 358 visitor->trace(m_callback); |
| 357 visitor->trace(m_observations); | 359 visitor->trace(m_observations); |
| 358 visitor->trace(m_entries); | 360 visitor->trace(m_entries); |
| 359 } | 361 } |
| 360 | 362 |
| 361 } // namespace blink | 363 } // namespace blink |
| OLD | NEW |