/** * Skip over one CSS comment starting at the current read position. */ void nsCSSScanner::SkipComment() { MOZ_ASSERT(Peek() == '/' && Peek(1) == '*', "should not have been called"); Advance(2); for (;;) { int32_t ch = Peek(); if (ch < 0) { if (mReporter) mReporter->ReportUnexpectedEOF("PECommentEOF"); SetEOFCharacters(eEOFCharacters_Asterisk | eEOFCharacters_Slash); return; } if (ch == '*') { Advance(); ch = Peek(); if (ch < 0) { if (mReporter) mReporter->ReportUnexpectedEOF("PECommentEOF"); SetEOFCharacters(eEOFCharacters_Slash); return; } if (ch == '/') { Advance(); return; } } else if (IsVertSpace(ch)) { AdvanceLine(); } else { Advance(); } } }
/** * Skip over a sequence of whitespace characters (vertical or * horizontal) starting at the current read position. */ void nsCSSScanner::SkipWhitespace() { for (;;) { int32_t ch = Peek(); if (!IsWhitespace(ch)) { // EOF counts as non-whitespace break; } if (IsVertSpace(ch)) { AdvanceLine(); } else { Advance(); } } }
void Render() { if (!mLine) { return; } // Update elapsed time mElapsedTime = timeGetTime() - mMovieStarted; // Update current line AdvanceLine(); // Should we display the current line? if (IsCurrentLineVisible()) { RenderCurrentLine(); } }
/** * If there is a valid escape sequence starting at the current read * position, consume it, decode it, append the result to |aOutput|, * and return true. Otherwise, consume nothing, leave |aOutput| * unmodified, and return false. If |aInString| is true, accept the * additional form of escape sequence allowed within string-like tokens. */ bool nsCSSScanner::GatherEscape(nsString& aOutput, bool aInString) { MOZ_ASSERT(Peek() == '\\', "should not have been called"); int32_t ch = Peek(1); if (ch < 0) { // If we are in a string (or a url() containing a string), we want to drop // the backslash on the floor. Otherwise, we want to treat it as a U+FFFD // character. Advance(); if (aInString) { SetEOFCharacters(eEOFCharacters_DropBackslash); } else { aOutput.Append(UCS2_REPLACEMENT_CHAR); SetEOFCharacters(eEOFCharacters_ReplacementChar); } return true; } if (IsVertSpace(ch)) { if (aInString) { // In strings (and in url() containing a string), escaped // newlines are completely removed, to allow splitting over // multiple lines. Advance(); AdvanceLine(); return true; } // Outside of strings, backslash followed by a newline is not an escape. return false; } if (!IsHexDigit(ch)) { // "Any character (except a hexadecimal digit, linefeed, carriage // return, or form feed) can be escaped with a backslash to remove // its special meaning." -- CSS2.1 section 4.1.3 Advance(2); if (ch == 0) { aOutput.Append(UCS2_REPLACEMENT_CHAR); } else { aOutput.Append(ch); } return true; } // "[at most six hexadecimal digits following a backslash] stand // for the ISO 10646 character with that number, which must not be // zero. (It is undefined in CSS 2.1 what happens if a style sheet // does contain a character with Unicode codepoint zero.)" // -- CSS2.1 section 4.1.3 // At this point we know we have \ followed by at least one // hexadecimal digit, therefore the escape sequence is valid and we // can go ahead and consume the backslash. Advance(); uint32_t val = 0; int i = 0; do { val = val * 16 + HexDigitValue(ch); i++; Advance(); ch = Peek(); } while (i < 6 && IsHexDigit(ch)); // "Interpret the hex digits as a hexadecimal number. If this number is zero, // or is greater than the maximum allowed codepoint, return U+FFFD // REPLACEMENT CHARACTER" -- CSS Syntax Level 3 if (MOZ_UNLIKELY(val == 0)) { aOutput.Append(UCS2_REPLACEMENT_CHAR); } else { AppendUCS4ToUTF16(ENSURE_VALID_CHAR(val), aOutput); } // Consume exactly one whitespace character after a // hexadecimal escape sequence. if (IsVertSpace(ch)) { AdvanceLine(); } else if (IsHorzSpace(ch)) { Advance(); } return true; }