| 1 | /* |
| 2 | * Copyright (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
| 3 | * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Library General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Library General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Library General Public License |
| 16 | * along with this library; see the file COPYING.LIB. If not, write to |
| 17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | * Boston, MA 02110-1301, USA. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #pragma once |
| 23 | |
| 24 | #include "CounterContent.h" |
| 25 | #include "RenderText.h" |
| 26 | |
| 27 | namespace WebCore { |
| 28 | |
| 29 | class CounterNode; |
| 30 | |
| 31 | class RenderCounter final : public RenderText { |
| 32 | WTF_MAKE_ISO_ALLOCATED(RenderCounter); |
| 33 | public: |
| 34 | RenderCounter(Document&, const CounterContent&); |
| 35 | virtual ~RenderCounter(); |
| 36 | |
| 37 | static void destroyCounterNodes(RenderElement&); |
| 38 | static void destroyCounterNode(RenderElement&, const AtomicString& identifier); |
| 39 | static void rendererSubtreeAttached(RenderElement&); |
| 40 | static void rendererRemovedFromTree(RenderElement&); |
| 41 | static void rendererStyleChanged(RenderElement&, const RenderStyle* oldStyle, const RenderStyle* newStyle); |
| 42 | |
| 43 | void updateCounter(); |
| 44 | |
| 45 | private: |
| 46 | void willBeDestroyed() override; |
| 47 | |
| 48 | const char* renderName() const override; |
| 49 | bool isCounter() const override; |
| 50 | String originalText() const override; |
| 51 | |
| 52 | void computePreferredLogicalWidths(float leadWidth) override; |
| 53 | |
| 54 | CounterContent m_counter; |
| 55 | CounterNode* m_counterNode { nullptr }; |
| 56 | RenderCounter* m_nextForSameCounter { nullptr }; |
| 57 | friend class CounterNode; |
| 58 | }; |
| 59 | |
| 60 | } // namespace WebCore |
| 61 | |
| 62 | SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderCounter, isCounter()) |
| 63 | |
| 64 | #if ENABLE(TREE_DEBUGGING) |
| 65 | // Outside the WebCore namespace for ease of invocation from the debugger. |
| 66 | void showCounterRendererTree(const WebCore::RenderObject*, const char* counterName = nullptr); |
| 67 | #endif |
| 68 | |