1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/parser/html/nsHtml5TokenizerLoopPolicies.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,47 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef nsHtml5TokenizerLoopPolicies_h 1.9 +#define nsHtml5TokenizerLoopPolicies_h 1.10 + 1.11 +/** 1.12 + * This policy does not report tokenizer transitions anywhere. To be used 1.13 + * when _not_ viewing source. 1.14 + */ 1.15 +struct nsHtml5SilentPolicy 1.16 +{ 1.17 + static const bool reportErrors = false; 1.18 + static int32_t transition(nsHtml5Highlighter* aHighlighter, 1.19 + int32_t aState, 1.20 + bool aReconsume, 1.21 + int32_t aPos) 1.22 + { 1.23 + return aState; 1.24 + } 1.25 + static void completedNamedCharacterReference(nsHtml5Highlighter* aHighlighter) 1.26 + { 1.27 + } 1.28 +}; 1.29 + 1.30 +/** 1.31 + * This policy reports the tokenizer transitions to a highlighter. To be used 1.32 + * when viewing source. 1.33 + */ 1.34 +struct nsHtml5ViewSourcePolicy 1.35 +{ 1.36 + static const bool reportErrors = true; 1.37 + static int32_t transition(nsHtml5Highlighter* aHighlighter, 1.38 + int32_t aState, 1.39 + bool aReconsume, 1.40 + int32_t aPos) 1.41 + { 1.42 + return aHighlighter->Transition(aState, aReconsume, aPos); 1.43 + } 1.44 + static void completedNamedCharacterReference(nsHtml5Highlighter* aHighlighter) 1.45 + { 1.46 + aHighlighter->CompletedNamedCharacterReference(); 1.47 + } 1.48 +}; 1.49 + 1.50 +#endif // nsHtml5TokenizerLoopPolicies_h