blob: 14eada3c88650a5314bf5074a13a18bd811e20cb [file] [log] [blame]
antti@apple.come7468a42016-04-01 09:54:12 +00001/*
2 * Copyright (C) 2016 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef RenderTreeUpdater_h
27#define RenderTreeUpdater_h
28
29#include "RenderTreePosition.h"
30#include "StyleChange.h"
31#include "StyleUpdate.h"
32#include <wtf/HashMap.h>
33#include <wtf/HashSet.h>
34#include <wtf/ListHashSet.h>
35#include <wtf/RefPtr.h>
36#include <wtf/Vector.h>
37
38namespace WebCore {
39
40class ContainerNode;
41class Document;
42class Element;
43class Node;
44class RenderStyle;
45class Text;
46
47class RenderTreeUpdater {
48public:
49 RenderTreeUpdater(Document&);
50
51 void commit(std::unique_ptr<const Style::Update>);
52
53private:
54 void updateRenderTree(ContainerNode& root);
55 void updateTextRenderer(Text&);
56 void updateElementRenderer(Element&, const Style::ElementUpdate&);
57 void createRenderer(Element&, RenderStyle&);
58 void invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(Node&);
59 void updateBeforeOrAfterPseudoElement(Element&, PseudoId);
60
61 struct Parent {
62 Element* element { nullptr };
63 Style::Change styleChange { Style::NoChange };
64 Optional<RenderTreePosition> renderTreePosition;
65
66 Parent(ContainerNode& root);
67 Parent(Element&, Style::Change);
68 };
69 Parent& parent() { return m_parentStack.last(); }
70 RenderTreePosition& renderTreePosition();
71
72 void pushParent(Element&, Style::Change);
73 void popParent();
74 void popParentsToDepth(unsigned depth);
75
76 Document& m_document;
77 std::unique_ptr<const Style::Update> m_styleUpdate;
78
79 Vector<Parent> m_parentStack;
80
81 HashSet<Text*> m_invalidatedWhitespaceOnlyTextSiblings;
82};
83
84}
85#endif