[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e

rniwa at webkit.org rniwa at webkit.org
Fri Jan 21 14:58:06 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit 809f9979eda4adbc79913bb933c6c6a317be4c51
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jan 5 18:32:50 2011 +0000

    2011-01-05  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Eric Seidel.
    
            ApplyStyleCommand::applyRelativeFontStyleChange should take EditingStyle*
            https://bugs.webkit.org/show_bug.cgi?id=50641
    
            Modified applyRelativeFontStyleChange to take EditingStyle instead of CSSMutableStyleDeclaration.
            Also extracted the logic to obtain the font size delta from ApplyStyleCommand to EditingStyle.
            The font size delta is now stored as a member variable of EditingStyle as supposed to a property
            in CSSMutableStyleDeclration as soon as EditingStyle is instantiated.
    
            No new tests are added since this is a refactoring.
    
            * editing/ApplyStyleCommand.cpp:
            (WebCore::ApplyStyleCommand::doApply): Calls applyRelativeFontStyleChange.
            (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange): Takes EditingStyle.
            * editing/ApplyStyleCommand.h:
            * editing/EditingStyle.cpp:
            (WebCore::EditingStyle::EditingStyle): Initializes m_fontSizeDelta.
            (WebCore::EditingStyle::init): Ditto.
            (WebCore::EditingStyle::extractFontSizeDelta): Extracted from applyRelativeFontStyleChange.
            (WebCore::EditingStyle::isEmpty): Takes care of m_fontSizeDelta.
            (WebCore::EditingStyle::setStyle): Calls extractFontSizeDelta.
            (WebCore::EditingStyle::overrideWithStyle): Ditto.
            (WebCore::EditingStyle::clear): Initializes m_fontSizeDelta.
            (WebCore::EditingStyle::copy): Calls extractFontSizeDelta.
            * editing/EditingStyle.h:
            (WebCore::EditingStyle::fontSizeDelta): Added.
            (WebCore::EditingStyle::hasFontSizeDelta): Added.
            * editing/Editor.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75080 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 5736fdb..20d672b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,35 @@
+2011-01-05  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        ApplyStyleCommand::applyRelativeFontStyleChange should take EditingStyle*
+        https://bugs.webkit.org/show_bug.cgi?id=50641
+
+        Modified applyRelativeFontStyleChange to take EditingStyle instead of CSSMutableStyleDeclaration.
+        Also extracted the logic to obtain the font size delta from ApplyStyleCommand to EditingStyle.
+        The font size delta is now stored as a member variable of EditingStyle as supposed to a property
+        in CSSMutableStyleDeclration as soon as EditingStyle is instantiated.
+
+        No new tests are added since this is a refactoring.
+
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::doApply): Calls applyRelativeFontStyleChange.
+        (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange): Takes EditingStyle.
+        * editing/ApplyStyleCommand.h:
+        * editing/EditingStyle.cpp:
+        (WebCore::EditingStyle::EditingStyle): Initializes m_fontSizeDelta.
+        (WebCore::EditingStyle::init): Ditto.
+        (WebCore::EditingStyle::extractFontSizeDelta): Extracted from applyRelativeFontStyleChange.
+        (WebCore::EditingStyle::isEmpty): Takes care of m_fontSizeDelta.
+        (WebCore::EditingStyle::setStyle): Calls extractFontSizeDelta.
+        (WebCore::EditingStyle::overrideWithStyle): Ditto.
+        (WebCore::EditingStyle::clear): Initializes m_fontSizeDelta.
+        (WebCore::EditingStyle::copy): Calls extractFontSizeDelta.
+        * editing/EditingStyle.h:
+        (WebCore::EditingStyle::fontSizeDelta): Added.
+        (WebCore::EditingStyle::hasFontSizeDelta): Added.
+        * editing/Editor.h:
+
 2011-01-05  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/editing/ApplyStyleCommand.cpp b/WebCore/editing/ApplyStyleCommand.cpp
index 1973a94..71b6a27 100644
--- a/WebCore/editing/ApplyStyleCommand.cpp
+++ b/WebCore/editing/ApplyStyleCommand.cpp
@@ -525,7 +525,7 @@ void ApplyStyleCommand::doApply()
         // Apply any remaining styles to the inline elements.
         if (!m_style->isEmpty() || m_styledInlineElement || m_isInlineElementToRemoveFunction) {
             RefPtr<CSSMutableStyleDeclaration> style = m_style->style() ? m_style->style() : CSSMutableStyleDeclaration::create();
-            applyRelativeFontStyleChange(style.get());
+            applyRelativeFontStyleChange(m_style.get());
             applyInlineStyle(style.get());
         }
         break;
@@ -607,35 +607,13 @@ void ApplyStyleCommand::applyBlockStyle(CSSMutableStyleDeclaration *style)
         updateStartEnd(startRange->startPosition(), endRange->startPosition());
 }
 
-#define NoFontDelta (0.0f)
-#define MinimumFontSize (0.1f)
-
-void ApplyStyleCommand::applyRelativeFontStyleChange(CSSMutableStyleDeclaration *style)
+void ApplyStyleCommand::applyRelativeFontStyleChange(EditingStyle* style)
 {
-    RefPtr<CSSValue> value = style->getPropertyCSSValue(CSSPropertyFontSize);
-    if (value) {
-        // Explicit font size overrides any delta.
-        style->removeProperty(CSSPropertyWebkitFontSizeDelta);
-        return;
-    }
+    static const float MinimumFontSize = 0.1f;
 
-    // Get the adjustment amount out of the style.
-    value = style->getPropertyCSSValue(CSSPropertyWebkitFontSizeDelta);
-    if (!value)
-        return;
-    float adjustment = NoFontDelta;
-    if (value->cssValueType() == CSSValue::CSS_PRIMITIVE_VALUE) {
-        CSSPrimitiveValue *primitiveValue = static_cast<CSSPrimitiveValue *>(value.get());
-        if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_PX) {
-            // Only PX handled now. If we handle more types in the future, perhaps
-            // a switch statement here would be more appropriate.
-            adjustment = primitiveValue->getFloatValue();
-        }
-    }
-    style->removeProperty(CSSPropertyWebkitFontSizeDelta);
-    if (adjustment == NoFontDelta)
+    if (!style || !style->hasFontSizeDelta())
         return;
-    
+
     Position start = startPosition();
     Position end = endPosition();
     if (comparePositions(end, start) < 0) {
@@ -643,7 +621,7 @@ void ApplyStyleCommand::applyRelativeFontStyleChange(CSSMutableStyleDeclaration
         start = end;
         end = swap;
     }
-    
+
     // Join up any adjacent text nodes.
     if (start.node()->isTextNode()) {
         joinChildTextNodes(start.node()->parentNode(), start, end);
@@ -714,7 +692,7 @@ void ApplyStyleCommand::applyRelativeFontStyleChange(CSSMutableStyleDeclaration
 
         CSSMutableStyleDeclaration* inlineStyleDecl = element->getInlineStyleDecl();
         float currentFontSize = computedFontSize(node);
-        float desiredFontSize = max(MinimumFontSize, startingFontSizes.get(node) + adjustment);
+        float desiredFontSize = max(MinimumFontSize, startingFontSizes.get(node) + style->fontSizeDelta());
         RefPtr<CSSValue> value = inlineStyleDecl->getPropertyCSSValue(CSSPropertyFontSize);
         if (value) {
             inlineStyleDecl->removeProperty(CSSPropertyFontSize, true);
@@ -737,9 +715,6 @@ void ApplyStyleCommand::applyRelativeFontStyleChange(CSSMutableStyleDeclaration
         removeNodePreservingChildren(unstyledSpans[i].get());
 }
 
-#undef NoFontDelta
-#undef MinimumFontSize
-
 static Node* dummySpanAncestorForNode(const Node* node)
 {
     while (node && !isStyleSpan(node))
diff --git a/WebCore/editing/ApplyStyleCommand.h b/WebCore/editing/ApplyStyleCommand.h
index 44197cc..5f369ba 100644
--- a/WebCore/editing/ApplyStyleCommand.h
+++ b/WebCore/editing/ApplyStyleCommand.h
@@ -91,7 +91,7 @@ private:
 
     // style-application helpers
     void applyBlockStyle(CSSMutableStyleDeclaration*);
-    void applyRelativeFontStyleChange(CSSMutableStyleDeclaration*);
+    void applyRelativeFontStyleChange(EditingStyle*);
     void applyInlineStyle(CSSMutableStyleDeclaration*);
     void fixRangeAndApplyInlineStyle(CSSMutableStyleDeclaration*, const Position& start, const Position& end);
     void applyInlineStyleToNodeRange(CSSMutableStyleDeclaration*, Node* startNode, Node* pastEndNode);
diff --git a/WebCore/editing/EditingStyle.cpp b/WebCore/editing/EditingStyle.cpp
index 3e0ec95..8caf4b6 100644
--- a/WebCore/editing/EditingStyle.cpp
+++ b/WebCore/editing/EditingStyle.cpp
@@ -82,19 +82,24 @@ static PassRefPtr<CSSMutableStyleDeclaration> editingStyleFromComputedStyle(Pass
     return copyEditingProperties(style.get());
 }
 
+float EditingStyle::NoFontDelta = 0.0f;
+
 EditingStyle::EditingStyle()
     : m_shouldUseFixedDefaultFontSize(false)
+    , m_fontSizeDelta(NoFontDelta)
 {
 }
 
 EditingStyle::EditingStyle(Node* node)
     : m_shouldUseFixedDefaultFontSize(false)
+    , m_fontSizeDelta(NoFontDelta)
 {
     init(node);
 }
 
 EditingStyle::EditingStyle(const Position& position)
     : m_shouldUseFixedDefaultFontSize(false)
+    , m_fontSizeDelta(NoFontDelta)
 {
     init(position.node());
 }
@@ -102,7 +107,9 @@ EditingStyle::EditingStyle(const Position& position)
 EditingStyle::EditingStyle(const CSSStyleDeclaration* style)
     : m_mutableStyle(style->copy())
     , m_shouldUseFixedDefaultFontSize(false)
+    , m_fontSizeDelta(NoFontDelta)
 {
+    extractFontSizeDelta();
 }
 
 EditingStyle::~EditingStyle()
@@ -121,6 +128,7 @@ void EditingStyle::init(Node* node)
     }
 
     m_shouldUseFixedDefaultFontSize = computedStyleAtPosition->useFixedFontDefaultSize();
+    extractFontSizeDelta();
 }
 
 void EditingStyle::removeTextFillAndStrokeColorsIfNeeded(RenderStyle* renderStyle)
@@ -143,9 +151,33 @@ void EditingStyle::replaceFontSizeByKeywordIfPossible(RenderStyle* renderStyle,
         m_mutableStyle->setProperty(CSSPropertyFontSize, computedStyle->getFontSizeCSSValuePreferringKeyword()->cssText());
 }
 
+void EditingStyle::extractFontSizeDelta()
+{
+    if (m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize)) {
+        // Explicit font size overrides any delta.
+        m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta);
+        return;
+    }
+
+    // Get the adjustment amount out of the style.
+    RefPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitFontSizeDelta);
+    if (!value || value->cssValueType() != CSSValue::CSS_PRIMITIVE_VALUE)
+        return;
+
+    CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value.get());
+
+    // Only PX handled now. If we handle more types in the future, perhaps
+    // a switch statement here would be more appropriate.
+    if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_PX)
+        return;
+
+    m_fontSizeDelta = primitiveValue->getFloatValue();
+    m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta);
+}
+
 bool EditingStyle::isEmpty() const
 {
-    return !m_mutableStyle || m_mutableStyle->isEmpty();
+    return (!m_mutableStyle || m_mutableStyle->isEmpty()) && m_fontSizeDelta == NoFontDelta;
 }
 
 bool EditingStyle::textDirection(WritingDirection& writingDirection) const
@@ -181,6 +213,7 @@ void EditingStyle::setStyle(PassRefPtr<CSSMutableStyleDeclaration> style)
     // FIXME: We should be able to figure out whether or not font is fixed width for mutable style.
     // We need to check font-family is monospace as in FontDescription but we don't want to duplicate code here.
     m_shouldUseFixedDefaultFontSize = false;
+    extractFontSizeDelta();
 }
 
 void EditingStyle::overrideWithStyle(const CSSMutableStyleDeclaration* style)
@@ -190,12 +223,14 @@ void EditingStyle::overrideWithStyle(const CSSMutableStyleDeclaration* style)
     if (!m_mutableStyle)
         m_mutableStyle = CSSMutableStyleDeclaration::create();
     m_mutableStyle->merge(style);
+    extractFontSizeDelta();
 }
 
 void EditingStyle::clear()
 {
     m_mutableStyle.clear();
     m_shouldUseFixedDefaultFontSize = false;
+    m_fontSizeDelta = NoFontDelta;
 }
 
 PassRefPtr<EditingStyle> EditingStyle::copy() const
@@ -204,6 +239,7 @@ PassRefPtr<EditingStyle> EditingStyle::copy() const
     if (m_mutableStyle)
         copy->m_mutableStyle = m_mutableStyle->copy();
     copy->m_shouldUseFixedDefaultFontSize = m_shouldUseFixedDefaultFontSize;
+    copy->m_fontSizeDelta = m_fontSizeDelta;
     return copy;
 }
 
diff --git a/WebCore/editing/EditingStyle.h b/WebCore/editing/EditingStyle.h
index 786b695..a71b4ad 100644
--- a/WebCore/editing/EditingStyle.h
+++ b/WebCore/editing/EditingStyle.h
@@ -46,8 +46,9 @@ class RenderStyle;
 
 class EditingStyle : public RefCounted<EditingStyle> {
 public:
-    
+
     enum ShouldPreserveWritingDirection { PreserveWritingDirection, DoNotPreserveWritingDirection };
+    static float NoFontDelta;
 
     static PassRefPtr<EditingStyle> create()
     {
@@ -85,6 +86,9 @@ public:
     void removeNonEditingProperties();
     void prepareToApplyAt(const Position&, ShouldPreserveWritingDirection = DoNotPreserveWritingDirection);
 
+    float fontSizeDelta() const { return m_fontSizeDelta; }
+    bool hasFontSizeDelta() const { return m_fontSizeDelta != NoFontDelta; }
+
 private:
     EditingStyle();
     EditingStyle(Node*);
@@ -93,9 +97,11 @@ private:
     void init(Node*);
     void removeTextFillAndStrokeColorsIfNeeded(RenderStyle*);
     void replaceFontSizeByKeywordIfPossible(RenderStyle*, CSSComputedStyleDeclaration*);
+    void extractFontSizeDelta();
 
     RefPtr<CSSMutableStyleDeclaration> m_mutableStyle;
     bool m_shouldUseFixedDefaultFontSize;
+    float m_fontSizeDelta;
 };
 
 PassRefPtr<EditingStyle> editingStyleIncludingTypingStyle(const Position&);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list