2 * Copyright (c) 2009-2010 Mozilla Foundation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
23 package nu
.validator
.htmlparser
.impl
;
25 import nu
.validator
.htmlparser
.annotation
.Auto
;
28 public class StateSnapshot
<T
> implements TreeBuilderState
<T
> {
30 private final @Auto StackNode
<T
>[] stack
;
32 private final @Auto StackNode
<T
>[] listOfActiveFormattingElements
;
34 private final @Auto int[] templateModeStack
;
36 private final T formPointer
;
38 private final T headPointer
;
40 private final int mode
;
42 private final int originalMode
;
44 private final boolean framesetOk
;
46 private final boolean needToDropLF
;
48 private final boolean quirks
;
52 * @param listOfActiveFormattingElements
53 * @param templateModeStack
56 * @param deepTreeSurrogateParent
63 StateSnapshot(StackNode
<T
>[] stack
,
64 StackNode
<T
>[] listOfActiveFormattingElements
, int[] templateModeStack
, T formPointer
,
65 T headPointer
, int mode
, int originalMode
,
66 boolean framesetOk
, boolean needToDropLF
, boolean quirks
) {
68 this.listOfActiveFormattingElements
= listOfActiveFormattingElements
;
69 this.templateModeStack
= templateModeStack
;
70 this.formPointer
= formPointer
;
71 this.headPointer
= headPointer
;
73 this.originalMode
= originalMode
;
74 this.framesetOk
= framesetOk
;
75 this.needToDropLF
= needToDropLF
;
80 * @see nu.validator.htmlparser.impl.TreeBuilderState#getStack()
83 public StackNode
<T
>[] getStack() {
88 * @see nu.validator.htmlparser.impl.TreeBuilderState#getTemplateModeStack()
91 public int[] getTemplateModeStack() {
92 return templateModeStack
;
96 * @see nu.validator.htmlparser.impl.TreeBuilderState#getListOfActiveFormattingElements()
99 public StackNode
<T
>[] getListOfActiveFormattingElements() {
100 return listOfActiveFormattingElements
;
104 * @see nu.validator.htmlparser.impl.TreeBuilderState#getFormPointer()
107 public T
getFormPointer() {
112 * Returns the headPointer.
114 * @return the headPointer
117 public T
getHeadPointer() {
127 public int getMode() {
132 * Returns the originalMode.
134 * @return the originalMode
137 public int getOriginalMode() {
142 * Returns the framesetOk.
144 * @return the framesetOk
147 public boolean isFramesetOk() {
152 * Returns the needToDropLF.
154 * @return the needToDropLF
157 public boolean isNeedToDropLF() {
162 * Returns the quirks.
167 public boolean isQuirks() {
172 * @see nu.validator.htmlparser.impl.TreeBuilderState#getListOfActiveFormattingElementsLength()
175 public int getListOfActiveFormattingElementsLength() {
176 return listOfActiveFormattingElements
.length
;
180 * @see nu.validator.htmlparser.impl.TreeBuilderState#getStackLength()
183 public int getStackLength() {
188 * @see nu.validator.htmlparser.impl.TreeBuilderState#getTemplateModeStackLength()
191 public int getTemplateModeStackLength() {
192 return templateModeStack
.length
;
195 @SuppressWarnings("unused") private void destructor() {
196 for (int i
= 0; i
< stack
.length
; i
++) {
197 stack
[i
].release(null);
199 for (int i
= 0; i
< listOfActiveFormattingElements
.length
; i
++) {
200 if (listOfActiveFormattingElements
[i
] != null) {
201 listOfActiveFormattingElements
[i
].release(null);