Diff
Modified: trunk/Source/WebCore/ChangeLog (161730 => 161731)
--- trunk/Source/WebCore/ChangeLog 2014-01-11 04:44:31 UTC (rev 161730)
+++ trunk/Source/WebCore/ChangeLog 2014-01-11 05:02:01 UTC (rev 161731)
@@ -1,3 +1,34 @@
+2014-01-10 Simon Fraser <[email protected]>
+
+ Add TextAutoSizing.* for iOS, and fix DeviceOrientationController creation.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * dom/Document.cpp:
+ (WebCore::Document::Document):
+ * rendering/TextAutoSizing.cpp: Added.
+ (WebCore::cloneRenderStyleWithState):
+ (WebCore::TextAutoSizingKey::TextAutoSizingKey):
+ (WebCore::TextAutoSizingKey::~TextAutoSizingKey):
+ (WebCore::TextAutoSizingKey::operator=):
+ (WebCore::TextAutoSizingKey::ref):
+ (WebCore::TextAutoSizingKey::deref):
+ (WebCore::TextAutoSizingValue::numNodes):
+ (WebCore::TextAutoSizingValue::addNode):
+ (WebCore::TextAutoSizingValue::adjustNodeSizes):
+ (WebCore::TextAutoSizingValue::reset):
+ * rendering/TextAutoSizing.h: Added.
+ (WebCore::TextAutoSizingKey::doc):
+ (WebCore::TextAutoSizingKey::style):
+ (WebCore::TextAutoSizingKey::isValidDoc):
+ (WebCore::TextAutoSizingKey::isValidStyle):
+ (WebCore::TextAutoSizingKey::deletedKeyDoc):
+ (WebCore::TextAutoSizingKey::deletedKeyStyle):
+ (WebCore::operator==):
+ (WebCore::TextAutoSizingHash::hash):
+ (WebCore::TextAutoSizingHash::equal):
+ (WebCore::TextAutoSizingValue::create):
+ (WebCore::TextAutoSizingValue::TextAutoSizingValue):
+
2014-01-10 Joseph Pecoraro <[email protected]>
Fix GraphicsLayerCA.o for iOS. Unreviewed build fix.
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (161730 => 161731)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-01-11 04:44:31 UTC (rev 161730)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-01-11 05:02:01 UTC (rev 161731)
@@ -475,6 +475,8 @@
0F54DCE01880F901003EEDBB /* DOMGestureEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F54DCDD1880F901003EEDBB /* DOMGestureEvent.h */; };
0F54DCE11880F901003EEDBB /* DOMGestureEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F54DCDE1880F901003EEDBB /* DOMGestureEvent.mm */; };
0F54DCE21880F901003EEDBB /* DOMGestureEventInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F54DCDF1880F901003EEDBB /* DOMGestureEventInternal.h */; };
+ 0F54DCE51881051D003EEDBB /* TextAutoSizing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F54DCE31881051D003EEDBB /* TextAutoSizing.cpp */; };
+ 0F54DCE61881051D003EEDBB /* TextAutoSizing.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F54DCE41881051D003EEDBB /* TextAutoSizing.h */; };
0F56028F0E4B76580065B038 /* RenderMarquee.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F56028D0E4B76580065B038 /* RenderMarquee.h */; };
0F5602900E4B76580065B038 /* RenderMarquee.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F56028E0E4B76580065B038 /* RenderMarquee.cpp */; };
0F580B0C0F12A2690051D689 /* GraphicsLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F580B090F12A2690051D689 /* GraphicsLayer.cpp */; };
@@ -7237,9 +7239,11 @@
0F54DCD21880F867003EEDBB /* DOMTouchInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMTouchInternal.h; sourceTree = "<group>"; };
0F54DCD31880F867003EEDBB /* DOMTouchList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMTouchList.h; sourceTree = "<group>"; };
0F54DCD41880F867003EEDBB /* DOMTouchList.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMTouchList.mm; sourceTree = "<group>"; };
- 0F54DCDD1880F901003EEDBB /* DOMGestureEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DOMGestureEvent.h; path = "DOMGestureEvent.h"; sourceTree = "<group>"; };
- 0F54DCDE1880F901003EEDBB /* DOMGestureEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DOMGestureEvent.mm; path = "DOMGestureEvent.mm"; sourceTree = "<group>"; };
- 0F54DCDF1880F901003EEDBB /* DOMGestureEventInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DOMGestureEventInternal.h; path = "DOMGestureEventInternal.h"; sourceTree = "<group>"; };
+ 0F54DCDD1880F901003EEDBB /* DOMGestureEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMGestureEvent.h; sourceTree = "<group>"; };
+ 0F54DCDE1880F901003EEDBB /* DOMGestureEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMGestureEvent.mm; sourceTree = "<group>"; };
+ 0F54DCDF1880F901003EEDBB /* DOMGestureEventInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMGestureEventInternal.h; sourceTree = "<group>"; };
+ 0F54DCE31881051D003EEDBB /* TextAutoSizing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextAutoSizing.cpp; sourceTree = "<group>"; };
+ 0F54DCE41881051D003EEDBB /* TextAutoSizing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextAutoSizing.h; sourceTree = "<group>"; };
0F56028D0E4B76580065B038 /* RenderMarquee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMarquee.h; sourceTree = "<group>"; };
0F56028E0E4B76580065B038 /* RenderMarquee.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMarquee.cpp; sourceTree = "<group>"; };
0F580B090F12A2690051D689 /* GraphicsLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsLayer.cpp; sourceTree = "<group>"; };
@@ -21902,6 +21906,8 @@
E4E9B11A18145692003ACCDF /* SimpleLineLayoutFunctions.cpp */,
E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */,
E4E9B1181810916F003ACCDF /* SimpleLineLayoutResolver.h */,
+ 0F54DCE31881051D003EEDBB /* TextAutoSizing.cpp */,
+ 0F54DCE41881051D003EEDBB /* TextAutoSizing.h */,
E4C91A0F1802343900A17F6D /* TextPaintStyle.cpp */,
E4C91A0D1802343100A17F6D /* TextPaintStyle.h */,
37FC96DA1104ED71003E1FAD /* TrailingFloatsRootInlineBox.h */,
@@ -25431,6 +25437,7 @@
A7B761A1161EE526002083D3 /* StyleScopeResolver.h in Headers */,
3138A9E51474434600B0ED12 /* StyleShader.h in Headers */,
A8EA800C0A19516E00A8EF5F /* StyleSheet.h in Headers */,
+ 0F54DCE61881051D003EEDBB /* TextAutoSizing.h in Headers */,
E4F9EEF3156DA00700D23E7E /* StyleSheetContents.h in Headers */,
A8EA800A0A19516E00A8EF5F /* StyleSheetList.h in Headers */,
BC5EB5E50E81BF6D00B25965 /* StyleSurroundData.h in Headers */,
@@ -28546,6 +28553,7 @@
4998AED113FB224D0090B1AA /* ScriptedAnimationController.cpp in Sources */,
08A484770E5272C500C3FE76 /* ScriptElement.cpp in Sources */,
E11C9DB00EB3699500E409DB /* ScriptExecutionContext.cpp in Sources */,
+ 0F54DCE51881051D003EEDBB /* TextAutoSizing.cpp in Sources */,
41F066E50F64BCF600A07EAC /* ScriptGlobalObject.cpp in Sources */,
FD31603512B0267600C1A359 /* ScriptProcessorNode.cpp in Sources */,
F33F0282120947F200E5743A /* ScriptProfile.cpp in Sources */,
Modified: trunk/Source/WebCore/dom/Document.cpp (161730 => 161731)
--- trunk/Source/WebCore/dom/Document.cpp 2014-01-11 04:44:31 UTC (rev 161730)
+++ trunk/Source/WebCore/dom/Document.cpp 2014-01-11 05:02:01 UTC (rev 161731)
@@ -481,7 +481,7 @@
, m_deviceMotionClient(DeviceMotionClientIOS::create())
, m_deviceMotionController(DeviceMotionController::create(m_deviceMotionClient.get()))
, m_deviceOrientationClient(DeviceOrientationClientIOS::create())
- , m_deviceOrientationController(DeviceOrientationController::create(frame ? frame->page() : nullptr, m_deviceOrientationClient.get()))
+ , m_deviceOrientationController(DeviceOrientationController::create(m_deviceOrientationClient.get()))
#endif
, m_isTelephoneNumberParsingAllowed(true)
#endif
Added: trunk/Source/WebCore/rendering/TextAutoSizing.cpp (0 => 161731)
--- trunk/Source/WebCore/rendering/TextAutoSizing.cpp (rev 0)
+++ trunk/Source/WebCore/rendering/TextAutoSizing.cpp 2014-01-11 05:02:01 UTC (rev 161731)
@@ -0,0 +1,249 @@
+/*
+ * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TextAutoSizing.h"
+
+#if ENABLE(IOS_TEXT_AUTOSIZING)
+
+#include "CSSFontSelector.h"
+#include "Document.h"
+#include "RenderListMarker.h"
+#include "RenderText.h"
+#include "StyleResolver.h"
+
+namespace WebCore {
+
+static PassRefPtr<RenderStyle> cloneRenderStyleWithState(const RenderStyle& currentStyle)
+{
+ RefPtr<RenderStyle> newStyle = RenderStyle::clone(¤tStyle);
+ if (currentStyle.lastChildState())
+ newStyle->setLastChildState();
+ if (currentStyle.firstChildState())
+ newStyle->setFirstChildState();
+ return newStyle.release();
+}
+
+TextAutoSizingKey::TextAutoSizingKey()
+ : m_style(0)
+ , m_doc(0)
+{
+}
+
+TextAutoSizingKey::TextAutoSizingKey(RenderStyle* style, Document* doc)
+ : m_style(style)
+ , m_doc(doc)
+{
+ ref();
+}
+
+TextAutoSizingKey::TextAutoSizingKey(const TextAutoSizingKey& other)
+ : m_style(other.m_style)
+ , m_doc(other.m_doc)
+{
+ ref();
+}
+
+TextAutoSizingKey::~TextAutoSizingKey()
+{
+ deref();
+}
+
+TextAutoSizingKey& TextAutoSizingKey::operator=(const TextAutoSizingKey& other)
+{
+ other.ref();
+ deref();
+ m_style = other.m_style;
+ m_doc = other.m_doc;
+ return *this;
+}
+
+void TextAutoSizingKey::ref() const
+{
+ if (isValidStyle())
+ m_style->ref();
+}
+
+void TextAutoSizingKey::deref() const
+{
+ if (isValidStyle() && isValidDoc())
+ m_style->deref();
+}
+
+int TextAutoSizingValue::numNodes() const
+{
+ return m_autoSizedNodes.size();
+}
+
+void TextAutoSizingValue::addNode(Node* node, float size)
+{
+ ASSERT(node);
+ RenderText* renderText = toRenderText(node->renderer());
+ renderText->setCandidateComputedTextSize(size);
+ m_autoSizedNodes.add(node);
+}
+
+#define MAX_SCALE_INCREASE 1.7f
+
+bool TextAutoSizingValue::adjustNodeSizes()
+{
+ bool objectsRemoved = false;
+
+ // Remove stale nodes. Nodes may have had their renderers detached. We'll
+ // also need to remove the style from the documents m_textAutoSizedNodes
+ // collection. Return true indicates we need to do that removal.
+ Vector<RefPtr<Node> > nodesForRemoval;
+ HashSet<RefPtr<Node> >::iterator end = m_autoSizedNodes.end();
+ for (HashSet<RefPtr<Node> >::iterator i = m_autoSizedNodes.begin(); i != end; ++i) {
+ RefPtr<Node> autoSizingNode = *i;
+ RenderText* text = static_cast<RenderText*>(autoSizingNode->renderer());
+ if (!text || !text->style().textSizeAdjust().isAuto() || !text->candidateComputedTextSize()) {
+ // remove node.
+ nodesForRemoval.append(autoSizingNode);
+ objectsRemoved = true;
+ }
+ }
+
+ unsigned count = nodesForRemoval.size();
+ for (unsigned i = 0; i < count; i++)
+ m_autoSizedNodes.remove(nodesForRemoval[i]);
+
+ // If we only have one piece of text with the style on the page don't
+ // adjust it's size.
+ if (m_autoSizedNodes.size() <= 1)
+ return objectsRemoved;
+
+ // Compute average size
+ float cumulativeSize = 0;
+ end = m_autoSizedNodes.end();
+ for (HashSet<RefPtr<Node> >::iterator i = m_autoSizedNodes.begin(); i != end; ++i) {
+ RefPtr<Node> autoSizingNode = *i;
+ RenderText* renderText = static_cast<RenderText*>(autoSizingNode->renderer());
+ cumulativeSize += renderText->candidateComputedTextSize();
+ }
+
+ float averageSize = roundf(cumulativeSize / m_autoSizedNodes.size());
+
+ // Adjust sizes
+ bool firstPass = true;
+ end = m_autoSizedNodes.end();
+ for (HashSet<RefPtr<Node> >::iterator i = m_autoSizedNodes.begin(); i != end; ++i) {
+ const RefPtr<Node>& autoSizingNode = *i;
+ RenderText* text = static_cast<RenderText*>(autoSizingNode->renderer());
+ if (text && text->style().fontDescription().computedSize() != averageSize) {
+ float specifiedSize = text->style().fontDescription().specifiedSize();
+ float scaleChange = averageSize / specifiedSize;
+ if (scaleChange > MAX_SCALE_INCREASE && firstPass) {
+ firstPass = false;
+ averageSize = roundf(specifiedSize * MAX_SCALE_INCREASE);
+ scaleChange = averageSize / specifiedSize;
+ }
+
+ RefPtr<RenderStyle> style = cloneRenderStyleWithState(text->style());
+ FontDescription fontDescription = style->fontDescription();
+ fontDescription.setComputedSize(averageSize);
+ style->setFontDescription(fontDescription);
+ style->font().update(autoSizingNode->document().ensureStyleResolver().fontSelector());
+ text->parent()->setStyle(style.releaseNonNull());
+
+ RenderElement* parentRenderer = text->parent();
+ if (parentRenderer->isAnonymousBlock())
+ parentRenderer = parentRenderer->parent();
+
+ // If we have a list we should resize ListMarkers separately.
+ RenderObject* listMarkerRenderer = parentRenderer->firstChild();
+ if (listMarkerRenderer->isListMarker()) {
+ RefPtr<RenderStyle> style = cloneRenderStyleWithState(listMarkerRenderer->style());
+ style->setFontDescription(fontDescription);
+ style->font().update(autoSizingNode->document().ensureStyleResolver().fontSelector());
+ toRenderListMarker(*listMarkerRenderer).setStyle(style.releaseNonNull());
+ }
+
+ // Resize the line height of the parent.
+ const RenderStyle& parentStyle = parentRenderer->style();
+ Length lineHeightLength = parentStyle.specifiedLineHeight();
+
+ int specifiedLineHeight = 0;
+ if (lineHeightLength.isPercent())
+ specifiedLineHeight = minimumValueForLength(lineHeightLength, fontDescription.specifiedSize());
+ else
+ specifiedLineHeight = lineHeightLength.value();
+
+ int lineHeight = specifiedLineHeight * scaleChange;
+ if (!lineHeightLength.isFixed() || lineHeightLength.value() != lineHeight) {
+ RefPtr<RenderStyle> newParentStyle = cloneRenderStyleWithState(parentStyle);
+ newParentStyle->setLineHeight(Length(lineHeight, Fixed));
+ newParentStyle->setSpecifiedLineHeight(lineHeightLength);
+ newParentStyle->setFontDescription(fontDescription);
+ newParentStyle->font().update(autoSizingNode->document().ensureStyleResolver().fontSelector());
+ parentRenderer->setStyle(newParentStyle.releaseNonNull());
+ }
+ }
+ }
+
+ return objectsRemoved;
+}
+
+void TextAutoSizingValue::reset()
+{
+ HashSet<RefPtr<Node> >::iterator end = m_autoSizedNodes.end();
+ for (HashSet<RefPtr<Node> >::iterator i = m_autoSizedNodes.begin(); i != end; ++i) {
+ const RefPtr<Node>& autoSizingNode = *i;
+ RenderText* text = static_cast<RenderText*>(autoSizingNode->renderer());
+ if (!text)
+ continue;
+ // Reset the font size back to the original specified size
+ FontDescription fontDescription = text->style().fontDescription();
+ float originalSize = fontDescription.specifiedSize();
+ if (fontDescription.computedSize() != originalSize) {
+ fontDescription.setComputedSize(originalSize);
+ RefPtr<RenderStyle> style = cloneRenderStyleWithState(text->style());
+ style->setFontDescription(fontDescription);
+ style->font().update(autoSizingNode->document().ensureStyleResolver().fontSelector());
+ text->parent()->setStyle(style.releaseNonNull());
+ }
+ // Reset the line height of the parent.
+ RenderElement* parentRenderer = text->parent();
+ if (!parentRenderer)
+ continue;
+
+ if (parentRenderer->isAnonymousBlock())
+ parentRenderer = parentRenderer->parent();
+
+ const RenderStyle& parentStyle = parentRenderer->style();
+ Length originalLineHeight = parentStyle.specifiedLineHeight();
+ if (originalLineHeight != parentStyle.lineHeight()) {
+ RefPtr<RenderStyle> newParentStyle = cloneRenderStyleWithState(parentStyle);
+ newParentStyle->setLineHeight(originalLineHeight);
+ newParentStyle->setFontDescription(fontDescription);
+ newParentStyle->font().update(autoSizingNode->document().ensureStyleResolver().fontSelector());
+ parentRenderer->setStyle(newParentStyle.releaseNonNull());
+ }
+ }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(IOS_TEXT_AUTOSIZING)
Property changes on: trunk/Source/WebCore/rendering/TextAutoSizing.cpp
___________________________________________________________________
Added: svn:keywords
Added: svn:eol-style
Added: trunk/Source/WebCore/rendering/TextAutoSizing.h (0 => 161731)
--- trunk/Source/WebCore/rendering/TextAutoSizing.h (rev 0)
+++ trunk/Source/WebCore/rendering/TextAutoSizing.h 2014-01-11 05:02:01 UTC (rev 161731)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TextAutoSizing_h
+#define TextAutoSizing_h
+
+#if ENABLE(IOS_TEXT_AUTOSIZING)
+
+#include "RenderStyle.h"
+#include <wtf/HashSet.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class Document;
+class Node;
+
+class TextAutoSizingKey {
+public:
+ TextAutoSizingKey();
+ TextAutoSizingKey(RenderStyle*, Document*);
+ ~TextAutoSizingKey();
+ TextAutoSizingKey(const TextAutoSizingKey&);
+ TextAutoSizingKey& operator=(const TextAutoSizingKey&);
+ Document* doc() const { return m_doc; }
+ RenderStyle* style() const { return m_style; }
+ inline bool isValidDoc() const { return m_doc && m_doc != deletedKeyDoc(); }
+ inline bool isValidStyle() const { return m_style && m_style != deletedKeyStyle(); }
+ static Document* deletedKeyDoc() { return reinterpret_cast<Document*>(-1); }
+ static RenderStyle* deletedKeyStyle() { return reinterpret_cast<RenderStyle*>(-1); }
+private:
+ void ref() const;
+ void deref() const;
+ RenderStyle* m_style;
+ Document* m_doc;
+};
+
+inline bool operator==(const TextAutoSizingKey& a, const TextAutoSizingKey& b)
+{
+ if (a.isValidStyle() && b.isValidStyle())
+ return a.style()->equalForTextAutosizing(b.style());
+ return a.style() == b.style();
+}
+
+struct TextAutoSizingHash {
+ static unsigned hash(const TextAutoSizingKey& key) { return key.style()->hashForTextAutosizing(); }
+ static bool equal(const TextAutoSizingKey& a, const TextAutoSizingKey& b) { return a == b; }
+ static const bool safeToCompareToEmptyOrDeleted = true;
+};
+
+class TextAutoSizingValue : public RefCounted<TextAutoSizingValue> {
+public:
+ static PassRefPtr<TextAutoSizingValue> create()
+ {
+ return adoptRef(new TextAutoSizingValue);
+ }
+
+ void addNode(Node*, float size);
+ bool adjustNodeSizes();
+ int numNodes() const;
+ void reset();
+private:
+ TextAutoSizingValue() { }
+ HashSet<RefPtr<Node> > m_autoSizedNodes;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(IOS_TEXT_AUTOSIZING)
+
+#endif // TextAutoSizing_h
Property changes on: trunk/Source/WebCore/rendering/TextAutoSizing.h
___________________________________________________________________
Added: svn:keywords
Added: svn:eol-style