Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Unified Diff: Source/core/dom/FirstLetterPseudoElement.h

Issue 571603003: Convert first letter into a pseudo element. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase to master Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/FirstLetterPseudoElement.h
diff --git a/Source/core/dom/FirstLetterPseudoElement.h b/Source/core/dom/FirstLetterPseudoElement.h
new file mode 100644
index 0000000000000000000000000000000000000000..dcb3ffac85b028230caa1f02a68dac1dde7db60c
--- /dev/null
+++ b/Source/core/dom/FirstLetterPseudoElement.h
@@ -0,0 +1,55 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef FirstLetterPseudoElement_h
+#define FirstLetterPseudoElement_h
+
+#include "core/dom/Document.h"
+#include "core/dom/PseudoElement.h"
+#include "wtf/text/WTFString.h"
+
+namespace blink {
+
+class Element;
+class RenderObject;
+
+class FirstLetterPseudoElement FINAL : public PseudoElement {
+WTF_MAKE_NONCOPYABLE(FirstLetterPseudoElement);
+public:
+ static RenderObject* firstLetterTextRenderer(const Element&);
+ static unsigned firstLetterLength(const String&);
+
+ void setRemainingTextRenderer(RenderTextFragment* fragment) { m_remainingTextRenderer = fragment; }
+ RenderTextFragment* remainingTextRenderer() const { return m_remainingTextRenderer; }
+
+ void setNeedsUpdate()
+ {
+ m_needsUpdate = true;
+ setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::PseudoClass));
+ }
+
+ bool needsUpdate() const {return m_needsUpdate; }
+
+ virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
+ virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
+
+private:
+ friend class PseudoElement; // For constructor.
+
+ FirstLetterPseudoElement(Element*);
+
+ virtual void didRecalcStyle(StyleRecalcChange) OVERRIDE;
+
+ void attachFirstLetterTextRenderers();
+ RenderStyle* styleForFirstLetter(RenderObject*);
+
+ RenderTextFragment* m_remainingTextRenderer;
+ bool m_needsUpdate;
+};
+
+DEFINE_ELEMENT_TYPE_CASTS(FirstLetterPseudoElement, isFirstLetterPseudoElement());
+
+} // namespace blink
+
+#endif // FirstLetterPseudoElement_h

Powered by Google App Engine
This is Rietveld 408576698