blob: 6d7780dc07f1721332b0c7228e1cfb5cc227de45 [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
commit-queue@webkit.org46c0f522016-11-13 10:05:43 +000026#pragma once
antti@apple.come7468a42016-04-01 09:54:12 +000027
28#include "RenderTreePosition.h"
29#include "StyleChange.h"
30#include "StyleUpdate.h"
31#include <wtf/HashMap.h>
32#include <wtf/HashSet.h>
antti@apple.come7468a42016-04-01 09:54:12 +000033#include <wtf/RefPtr.h>
34#include <wtf/Vector.h>
35
36namespace WebCore {
37
38class ContainerNode;
39class Document;
40class Element;
41class Node;
42class RenderStyle;
43class Text;
44
45class RenderTreeUpdater {
46public:
47 RenderTreeUpdater(Document&);
48
antti@apple.com9957b2d2016-12-14 16:06:50 +000049 void commit(std::unique_ptr<const Style::Update>);
antti@apple.come7468a42016-04-01 09:54:12 +000050
antti@apple.com07bd6d62016-04-05 15:04:02 +000051 enum class TeardownType { Normal, KeepHoverAndActive };
52 static void tearDownRenderers(Element&, TeardownType = TeardownType::Normal);
53 static void tearDownRenderer(Text&);
54
antti@apple.come7468a42016-04-01 09:54:12 +000055private:
56 void updateRenderTree(ContainerNode& root);
57 void updateTextRenderer(Text&);
antti@apple.com9957b2d2016-12-14 16:06:50 +000058 void updateElementRenderer(Element&, const Style::ElementUpdate&);
antti@apple.com454418f2016-04-25 19:49:23 +000059 void createRenderer(Element&, RenderStyle&&);
antti@apple.come7468a42016-04-01 09:54:12 +000060 void invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(Node&);
61 void updateBeforeOrAfterPseudoElement(Element&, PseudoId);
62
63 struct Parent {
64 Element* element { nullptr };
65 Style::Change styleChange { Style::NoChange };
utatane.tea@gmail.com43926962016-11-27 06:08:16 +000066 std::optional<RenderTreePosition> renderTreePosition;
antti@apple.come7468a42016-04-01 09:54:12 +000067
68 Parent(ContainerNode& root);
69 Parent(Element&, Style::Change);
70 };
71 Parent& parent() { return m_parentStack.last(); }
72 RenderTreePosition& renderTreePosition();
73
74 void pushParent(Element&, Style::Change);
75 void popParent();
76 void popParentsToDepth(unsigned depth);
77
78 Document& m_document;
antti@apple.com9957b2d2016-12-14 16:06:50 +000079 std::unique_ptr<const Style::Update> m_styleUpdate;
antti@apple.come7468a42016-04-01 09:54:12 +000080
81 Vector<Parent> m_parentStack;
82
83 HashSet<Text*> m_invalidatedWhitespaceOnlyTextSiblings;
84};
85
commit-queue@webkit.org46c0f522016-11-13 10:05:43 +000086} // namespace WebCore