antti@apple.com | e7468a4 | 2016-04-01 09:54:12 +0000 | [diff] [blame] | 1 | /* |
| 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.org | 46c0f52 | 2016-11-13 10:05:43 +0000 | [diff] [blame] | 26 | #pragma once |
antti@apple.com | e7468a4 | 2016-04-01 09:54:12 +0000 | [diff] [blame] | 27 | |
| 28 | #include "RenderTreePosition.h" |
| 29 | #include "StyleChange.h" |
| 30 | #include "StyleUpdate.h" |
| 31 | #include <wtf/HashMap.h> |
| 32 | #include <wtf/HashSet.h> |
antti@apple.com | e7468a4 | 2016-04-01 09:54:12 +0000 | [diff] [blame] | 33 | #include <wtf/RefPtr.h> |
| 34 | #include <wtf/Vector.h> |
| 35 | |
| 36 | namespace WebCore { |
| 37 | |
| 38 | class ContainerNode; |
| 39 | class Document; |
| 40 | class Element; |
| 41 | class Node; |
| 42 | class RenderStyle; |
| 43 | class Text; |
| 44 | |
| 45 | class RenderTreeUpdater { |
| 46 | public: |
| 47 | RenderTreeUpdater(Document&); |
| 48 | |
antti@apple.com | 9957b2d | 2016-12-14 16:06:50 +0000 | [diff] [blame] | 49 | void commit(std::unique_ptr<const Style::Update>); |
antti@apple.com | e7468a4 | 2016-04-01 09:54:12 +0000 | [diff] [blame] | 50 | |
antti@apple.com | 07bd6d6 | 2016-04-05 15:04:02 +0000 | [diff] [blame] | 51 | enum class TeardownType { Normal, KeepHoverAndActive }; |
| 52 | static void tearDownRenderers(Element&, TeardownType = TeardownType::Normal); |
| 53 | static void tearDownRenderer(Text&); |
| 54 | |
antti@apple.com | e7468a4 | 2016-04-01 09:54:12 +0000 | [diff] [blame] | 55 | private: |
| 56 | void updateRenderTree(ContainerNode& root); |
| 57 | void updateTextRenderer(Text&); |
antti@apple.com | 9957b2d | 2016-12-14 16:06:50 +0000 | [diff] [blame] | 58 | void updateElementRenderer(Element&, const Style::ElementUpdate&); |
antti@apple.com | 454418f | 2016-04-25 19:49:23 +0000 | [diff] [blame] | 59 | void createRenderer(Element&, RenderStyle&&); |
antti@apple.com | e7468a4 | 2016-04-01 09:54:12 +0000 | [diff] [blame] | 60 | 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.com | 4392696 | 2016-11-27 06:08:16 +0000 | [diff] [blame] | 66 | std::optional<RenderTreePosition> renderTreePosition; |
antti@apple.com | e7468a4 | 2016-04-01 09:54:12 +0000 | [diff] [blame] | 67 | |
| 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.com | 9957b2d | 2016-12-14 16:06:50 +0000 | [diff] [blame] | 79 | std::unique_ptr<const Style::Update> m_styleUpdate; |
antti@apple.com | e7468a4 | 2016-04-01 09:54:12 +0000 | [diff] [blame] | 80 | |
| 81 | Vector<Parent> m_parentStack; |
| 82 | |
| 83 | HashSet<Text*> m_invalidatedWhitespaceOnlyTextSiblings; |
| 84 | }; |
| 85 | |
commit-queue@webkit.org | 46c0f52 | 2016-11-13 10:05:43 +0000 | [diff] [blame] | 86 | } // namespace WebCore |