Title: [118076] trunk/Source/WebCore
Revision
118076
Author
[email protected]
Date
2012-05-22 16:05:33 -0700 (Tue, 22 May 2012)

Log Message

Represents margins as box and simplify writing mode logic
https://bugs.webkit.org/show_bug.cgi?id=86952

Reviewed by Eric Seidel.

Add a new class, FractionalLayoutBox, that represents the four sides of a
box and change RenderBox to use it to represent margins.

The new box class is intended to be used to represent things like
margins, paddings and borders where the current rect class isn't a good
fit. It also encapsulated a lot of the horizontal/vertical writing mode
and bidi logic allowing it to be reused.

No new tests, no change in functionality.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/FractionalLayoutBoxExtent.cpp: Added.
* platform/graphics/FractionalLayoutBoxExtent.h: Added.
* rendering/LayoutTypes.h:
* rendering/RenderBlock.cpp:
* rendering/RenderBox.cpp:
* rendering/RenderBox.h:
* rendering/RenderScrollbarPart.cpp:
* rendering/RenderScrollbarPart.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (118075 => 118076)


--- trunk/Source/WebCore/CMakeLists.txt	2012-05-22 22:58:53 UTC (rev 118075)
+++ trunk/Source/WebCore/CMakeLists.txt	2012-05-22 23:05:33 UTC (rev 118076)
@@ -1159,6 +1159,7 @@
     platform/graphics/FontFamily.cpp
     platform/graphics/FontFastPath.cpp
     platform/graphics/FontFeatureSettings.cpp
+    platform/graphics/FractionalLayoutBoxExtent.cpp
     platform/graphics/FractionalLayoutRect.cpp
     platform/graphics/GeneratorGeneratedImage.cpp
     platform/graphics/GlyphPageTreeNode.cpp

Modified: trunk/Source/WebCore/ChangeLog (118075 => 118076)


--- trunk/Source/WebCore/ChangeLog	2012-05-22 22:58:53 UTC (rev 118075)
+++ trunk/Source/WebCore/ChangeLog	2012-05-22 23:05:33 UTC (rev 118076)
@@ -1,3 +1,35 @@
+2012-05-22  Emil A Eklund  <[email protected]>
+
+        Represents margins as box and simplify writing mode logic
+        https://bugs.webkit.org/show_bug.cgi?id=86952
+
+        Reviewed by Eric Seidel.
+        
+        Add a new class, FractionalLayoutBox, that represents the four sides of a
+        box and change RenderBox to use it to represent margins.
+
+        The new box class is intended to be used to represent things like
+        margins, paddings and borders where the current rect class isn't a good
+        fit. It also encapsulated a lot of the horizontal/vertical writing mode
+        and bidi logic allowing it to be reused.
+
+        No new tests, no change in functionality.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/FractionalLayoutBoxExtent.cpp: Added.
+        * platform/graphics/FractionalLayoutBoxExtent.h: Added.
+        * rendering/LayoutTypes.h:
+        * rendering/RenderBlock.cpp:
+        * rendering/RenderBox.cpp:
+        * rendering/RenderBox.h:
+        * rendering/RenderScrollbarPart.cpp:
+        * rendering/RenderScrollbarPart.h:
+
 2012-05-22  Kentaro Hara  <[email protected]>
 
         [V8] Replace 'throwTypeError(); return Undefined();' with 'return throwTypeError();'

Modified: trunk/Source/WebCore/GNUmakefile.list.am (118075 => 118076)


--- trunk/Source/WebCore/GNUmakefile.list.am	2012-05-22 22:58:53 UTC (rev 118075)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2012-05-22 23:05:33 UTC (rev 118076)
@@ -3266,6 +3266,8 @@
 	Source/WebCore/platform/graphics/FontSmoothingMode.h \
 	Source/WebCore/platform/graphics/FontTraitsMask.h \
 	Source/WebCore/platform/graphics/FontWidthVariant.h \
+	Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.cpp \
+	Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.h \
 	Source/WebCore/platform/graphics/FractionalLayoutPoint.h \
 	Source/WebCore/platform/graphics/FractionalLayoutRect.cpp \
 	Source/WebCore/platform/graphics/FractionalLayoutRect.h \

Modified: trunk/Source/WebCore/Target.pri (118075 => 118076)


--- trunk/Source/WebCore/Target.pri	2012-05-22 22:58:53 UTC (rev 118075)
+++ trunk/Source/WebCore/Target.pri	2012-05-22 23:05:33 UTC (rev 118076)
@@ -1104,6 +1104,7 @@
     platform/graphics/FontData.cpp \
     platform/graphics/Font.cpp \
     platform/graphics/FontCache.cpp \
+    platform/graphics/FractionalLayoutBoxExtent.cpp \
     platform/graphics/FractionalLayoutRect.cpp \
     platform/graphics/GeneratorGeneratedImage.cpp \
     platform/graphics/Gradient.cpp \

Modified: trunk/Source/WebCore/WebCore.gypi (118075 => 118076)


--- trunk/Source/WebCore/WebCore.gypi	2012-05-22 22:58:53 UTC (rev 118075)
+++ trunk/Source/WebCore/WebCore.gypi	2012-05-22 23:05:33 UTC (rev 118076)
@@ -3441,6 +3441,7 @@
             'platform/graphics/FontFastPath.cpp',
             'platform/graphics/FontPlatformData.cpp',
             'platform/graphics/FontPlatformData.h',
+            'platform/graphics/FractionalLayoutBoxExtent.cpp',
             'platform/graphics/FractionalLayoutRect.cpp',
             'platform/graphics/GeneratorGeneratedImage.cpp',
             'platform/graphics/GeneratedImage.h',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (118075 => 118076)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-05-22 22:58:53 UTC (rev 118075)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-05-22 23:05:33 UTC (rev 118076)
@@ -28857,6 +28857,14 @@
 					>
 				</File>
 				<File
+					RelativePath="..\platform\graphics\FractionalLayoutBoxExtent.h"
+					>
+				</File>
+				<File
+					RelativePath="..\platform\graphics\FractionalLayoutBoxExtent.cpp"
+					>
+				</File>
+				<File
 					RelativePath="..\platform\graphics\FractionalLayoutPoint.h"
 					>
 				</File>

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (118075 => 118076)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-05-22 22:58:53 UTC (rev 118075)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-05-22 23:05:33 UTC (rev 118076)
@@ -294,6 +294,8 @@
 		1432E8490C51493F00B1500F /* GCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1432E8480C51493F00B1500F /* GCController.cpp */; };
 		1449E24C107D4A8400B5793F /* JSCallbackData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1449E24A107D4A8400B5793F /* JSCallbackData.h */; };
 		1449E287107D4DB400B5793F /* JSCallbackData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1449E286107D4DB400B5793F /* JSCallbackData.cpp */; };
+		1482E0C6156C36DE00965065 /* FractionalLayoutBoxExtent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1482E0C4156C36DE00965065 /* FractionalLayoutBoxExtent.cpp */; };
+		1482E0C7156C36DE00965065 /* FractionalLayoutBoxExtent.h in Headers */ = {isa = PBXBuildFile; fileRef = 1482E0C5156C36DE00965065 /* FractionalLayoutBoxExtent.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		144FCE5214EC79BC000D17A3 /* FractionalLayoutUnit.h in Headers */ = {isa = PBXBuildFile; fileRef = 144FCE5114EC79BC000D17A3 /* FractionalLayoutUnit.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		144FCE5D14EC79E7000D17A3 /* FractionalLayoutSize.h in Headers */ = {isa = PBXBuildFile; fileRef = 144FCE5814EC79E7000D17A3 /* FractionalLayoutSize.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		144FCFE014EF2509000D17A3 /* FractionalLayoutRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 144FCFDE14EF2509000D17A3 /* FractionalLayoutRect.cpp */; };
@@ -7180,6 +7182,8 @@
 		1432E8480C51493F00B1500F /* GCController.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GCController.cpp; sourceTree = "<group>"; };
 		1449E24A107D4A8400B5793F /* JSCallbackData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackData.h; sourceTree = "<group>"; };
 		1449E286107D4DB400B5793F /* JSCallbackData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCallbackData.cpp; sourceTree = "<group>"; };
+		1482E0C4156C36DE00965065 /* FractionalLayoutBoxExtent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FractionalLayoutBoxExtent.cpp; sourceTree = "<group>"; };
+		1482E0C5156C36DE00965065 /* FractionalLayoutBoxExtent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FractionalLayoutBoxExtent.h; sourceTree = "<group>"; };
 		144FCE5114EC79BC000D17A3 /* FractionalLayoutUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FractionalLayoutUnit.h; sourceTree = "<group>"; };
 		144FCE5414EC79E7000D17A3 /* FractionalLayoutPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FractionalLayoutPoint.h; sourceTree = "<group>"; };
 		144FCE5814EC79E7000D17A3 /* FractionalLayoutSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FractionalLayoutSize.h; sourceTree = "<group>"; };
@@ -19422,6 +19426,8 @@
 				37202198106213C600F25C4B /* FontSmoothingMode.h */,
 				3784C34A0E11AA34007D8D48 /* FontTraitsMask.h */,
 				BCE4413512F7490B009B84B8 /* FontWidthVariant.h */,
+				1482E0C4156C36DE00965065 /* FractionalLayoutBoxExtent.cpp */,
+				1482E0C5156C36DE00965065 /* FractionalLayoutBoxExtent.h */,
 				144FCE5414EC79E7000D17A3 /* FractionalLayoutPoint.h */,
 				144FCFDE14EF2509000D17A3 /* FractionalLayoutRect.cpp */,
 				144FCFDF14EF2509000D17A3 /* FractionalLayoutRect.h */,
@@ -24917,6 +24923,7 @@
 				29A309B11561CAC400BBD8E5 /* VisitedLinks.h in Headers */,
 				FDB052E01561A42C00B500D6 /* AudioSummingJunction.h in Headers */,
 				371941971566B37200A276D8 /* WebCoreNSCellExtras.h in Headers */,
+				1482E0C7156C36DE00965065 /* FractionalLayoutBoxExtent.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -27943,6 +27950,7 @@
 				FDB052DF1561A42C00B500D6 /* AudioSummingJunction.cpp in Sources */,
 				371941961566B37200A276D8 /* WebCoreNSCellExtras.m in Sources */,
 				146CC115156988E400109E37 /* LengthBox.cpp in Sources */,
+				1482E0C6156C36DE00965065 /* FractionalLayoutBoxExtent.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: trunk/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.cpp (0 => 118076)


--- trunk/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.cpp	2012-05-22 23:05:33 UTC (rev 118076)
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2012, Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 "FractionalLayoutBoxExtent.h"
+
+#include "RenderStyle.h"
+
+namespace WebCore {
+
+FractionalLayoutUnit FractionalLayoutBoxExtent::logicalLeft(const RenderStyle* style) const
+{
+    return style->isHorizontalWritingMode() ? m_left : m_top;
+}
+
+FractionalLayoutUnit FractionalLayoutBoxExtent::logicalRight(const RenderStyle* style) const
+{
+    return style->isHorizontalWritingMode() ? m_right : m_bottom;
+}
+
+FractionalLayoutUnit FractionalLayoutBoxExtent::before(const RenderStyle* style) const
+{
+    switch (style->writingMode()) {
+    case TopToBottomWritingMode:
+        return m_top;
+    case BottomToTopWritingMode:
+        return m_bottom;
+    case LeftToRightWritingMode:
+        return m_left;
+    case RightToLeftWritingMode:
+        return m_right;
+    }
+    ASSERT_NOT_REACHED();
+    return m_top;
+}
+
+FractionalLayoutUnit FractionalLayoutBoxExtent::after(const RenderStyle* style) const
+{
+    switch (style->writingMode()) {
+    case TopToBottomWritingMode:
+        return m_bottom;
+    case BottomToTopWritingMode:
+        return m_top;
+    case LeftToRightWritingMode:
+        return m_right;
+    case RightToLeftWritingMode:
+        return m_left;
+    }
+    ASSERT_NOT_REACHED();
+    return m_bottom;
+}
+
+FractionalLayoutUnit FractionalLayoutBoxExtent::start(const RenderStyle* style) const
+{
+    if (style->isHorizontalWritingMode())
+        return style->isLeftToRightDirection() ? m_left : m_right;
+    return style->isLeftToRightDirection() ? m_top : m_bottom;
+}
+
+FractionalLayoutUnit FractionalLayoutBoxExtent::end(const RenderStyle* style) const
+{
+    if (style->isHorizontalWritingMode())
+        return style->isLeftToRightDirection() ? m_right : m_left;
+    return style->isLeftToRightDirection() ? m_bottom : m_top;
+}
+
+void FractionalLayoutBoxExtent::setBefore(const RenderStyle* style, FractionalLayoutUnit value)
+{
+    switch (style->writingMode()) {
+    case TopToBottomWritingMode:
+        m_top = value;
+        break;
+    case BottomToTopWritingMode:
+        m_bottom = value;
+        break;
+    case LeftToRightWritingMode:
+        m_left = value;
+        break;
+    case RightToLeftWritingMode:
+        m_right = value;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        m_top = value;
+    }
+}
+
+void FractionalLayoutBoxExtent::setAfter(const RenderStyle* style, FractionalLayoutUnit value)
+{
+    switch (style->writingMode()) {
+    case TopToBottomWritingMode:
+        m_bottom = value;
+        break;
+    case BottomToTopWritingMode:
+        m_top = value;
+        break;
+    case LeftToRightWritingMode:
+        m_right = value;
+        break;
+    case RightToLeftWritingMode:
+        m_left = value;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        m_bottom = value;
+    }
+}
+
+void FractionalLayoutBoxExtent::setStart(const RenderStyle* style, FractionalLayoutUnit value)
+{
+    if (style->isHorizontalWritingMode()) {
+        if (style->isLeftToRightDirection())
+            m_left = value;
+        else
+            m_right = value;
+    } else {
+        if (style->isLeftToRightDirection())
+            m_top = value;
+        else
+            m_bottom = value;
+    }
+}
+
+void FractionalLayoutBoxExtent::setEnd(const RenderStyle* style, FractionalLayoutUnit value)
+{
+    if (style->isHorizontalWritingMode()) {
+        if (style->isLeftToRightDirection())
+            m_right = value;
+        else
+            m_left = value;
+    } else {
+        if (style->isLeftToRightDirection())
+            m_bottom = value;
+        else
+            m_top = value;
+    }
+}
+
+FractionalLayoutUnit& FractionalLayoutBoxExtent::mutableLogicalLeft(const RenderStyle* style)
+{
+    return style->isHorizontalWritingMode() ? m_left : m_top;
+}
+
+FractionalLayoutUnit& FractionalLayoutBoxExtent::mutableLogicalRight(const RenderStyle* style)
+{
+    return style->isHorizontalWritingMode() ? m_right : m_bottom;
+}
+
+FractionalLayoutUnit& FractionalLayoutBoxExtent::mutableBefore(const RenderStyle* style)
+{
+    return style->isHorizontalWritingMode() ? (style->isFlippedBlocksWritingMode() ? m_bottom : m_top) :
+                                              (style->isFlippedBlocksWritingMode() ? m_right: m_left);
+}
+
+FractionalLayoutUnit& FractionalLayoutBoxExtent::mutableAfter(const RenderStyle* style)
+{
+    return style->isHorizontalWritingMode() ? (style->isFlippedBlocksWritingMode() ? m_top : m_bottom) :
+                                              (style->isFlippedBlocksWritingMode() ? m_left: m_right);
+}
+
+} // namespace WebCore

Added: trunk/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.h (0 => 118076)


--- trunk/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.h	2012-05-22 23:05:33 UTC (rev 118076)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2012, Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 FractionalLayoutBoxExtent_h
+#define FractionalLayoutBoxExtent_h
+
+#include "FractionalLayoutUnit.h"
+
+namespace WebCore {
+
+class RenderStyle;
+
+class FractionalLayoutBoxExtent {
+public:
+    FractionalLayoutBoxExtent() : m_top(0), m_right(0), m_bottom(0), m_left(0) { }
+    FractionalLayoutBoxExtent(FractionalLayoutUnit top, FractionalLayoutUnit right, FractionalLayoutUnit bottom, FractionalLayoutUnit left)
+        : m_top(top), m_right(right), m_bottom(bottom), m_left(left) { }
+
+    inline FractionalLayoutUnit top() const { return m_top; }
+    inline FractionalLayoutUnit right() const { return m_right; }
+    inline FractionalLayoutUnit bottom() const { return m_bottom; }
+    inline FractionalLayoutUnit left() const { return m_left; }
+
+    inline void setTop(FractionalLayoutUnit value) { m_top = value; }
+    inline void setRight(FractionalLayoutUnit value) { m_right = value; }
+    inline void setBottom(FractionalLayoutUnit value) { m_bottom = value; }
+    inline void setLeft(FractionalLayoutUnit value) { m_left = value; }
+
+    FractionalLayoutUnit logicalLeft(const RenderStyle*) const;
+    FractionalLayoutUnit logicalRight(const RenderStyle*) const;
+
+    FractionalLayoutUnit before(const RenderStyle*) const;
+    FractionalLayoutUnit after(const RenderStyle*) const;
+    FractionalLayoutUnit start(const RenderStyle*) const;
+    FractionalLayoutUnit end(const RenderStyle*) const;
+
+    void setBefore(const RenderStyle*, FractionalLayoutUnit);
+    void setAfter(const RenderStyle*, FractionalLayoutUnit);
+    void setStart(const RenderStyle*, FractionalLayoutUnit);
+    void setEnd(const RenderStyle*, FractionalLayoutUnit);
+
+    FractionalLayoutUnit& mutableLogicalLeft(const RenderStyle*);
+    FractionalLayoutUnit& mutableLogicalRight(const RenderStyle*);
+
+    FractionalLayoutUnit& mutableBefore(const RenderStyle*);
+    FractionalLayoutUnit& mutableAfter(const RenderStyle*);
+
+private:
+    FractionalLayoutUnit m_top;
+    FractionalLayoutUnit m_right;
+    FractionalLayoutUnit m_bottom;
+    FractionalLayoutUnit m_left;
+};
+
+} // namespace WebCore
+
+#endif // FractionalLayoutBoxExtent_h

Modified: trunk/Source/WebCore/rendering/LayoutTypes.h (118075 => 118076)


--- trunk/Source/WebCore/rendering/LayoutTypes.h	2012-05-22 22:58:53 UTC (rev 118075)
+++ trunk/Source/WebCore/rendering/LayoutTypes.h	2012-05-22 23:05:33 UTC (rev 118076)
@@ -37,6 +37,7 @@
 #define LayoutTypes_h
 
 #include "FloatRect.h"
+#include "FractionalLayoutBoxExtent.h"
 #include "FractionalLayoutRect.h"
 #include "FractionalLayoutUnit.h"
 #include "IntRect.h"
@@ -49,6 +50,7 @@
 typedef FractionalLayoutPoint LayoutPoint;
 typedef FractionalLayoutSize LayoutSize;
 typedef FractionalLayoutRect LayoutRect;
+typedef FractionalLayoutBoxExtent LayoutBoxExtent;
 
 #define MAX_LAYOUT_UNIT LayoutUnit::max()
 #define MIN_LAYOUT_UNIT LayoutUnit::min()

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (118075 => 118076)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-05-22 22:58:53 UTC (rev 118075)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-05-22 23:05:33 UTC (rev 118076)
@@ -4329,7 +4329,7 @@
     if (!prev->m_floatingObjects)
         return;
 
-    logicalLeftOffset += (isHorizontalWritingMode() ? marginLeft() : marginTop());
+    logicalLeftOffset += marginLogicalLeft();
 
     const FloatingObjectSet& prevSet = prev->m_floatingObjects->set();
     FloatingObjectSetIterator prevEnd = prevSet.end();

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (118075 => 118076)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2012-05-22 22:58:53 UTC (rev 118075)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2012-05-22 23:05:33 UTC (rev 118076)
@@ -71,10 +71,6 @@
 
 RenderBox::RenderBox(Node* node)
     : RenderBoxModelObject(node)
-    , m_marginLeft(0)
-    , m_marginRight(0)
-    , m_marginTop(0)
-    , m_marginBottom(0)
     , m_minPreferredLogicalWidth(-1)
     , m_maxPreferredLogicalWidth(-1)
     , m_inlineBoxWrapper(0)
@@ -86,122 +82,6 @@
 {
 }
 
-LayoutUnit RenderBox::marginBefore(const RenderStyle* overrideStyle) const
-{
-    switch (overrideStyle ? overrideStyle->writingMode() : style()->writingMode()) {
-    case TopToBottomWritingMode:
-        return m_marginTop;
-    case BottomToTopWritingMode:
-        return m_marginBottom;
-    case LeftToRightWritingMode:
-        return m_marginLeft;
-    case RightToLeftWritingMode:
-        return m_marginRight;
-    }
-    ASSERT_NOT_REACHED();
-    return m_marginTop;
-}
-
-LayoutUnit RenderBox::marginAfter(const RenderStyle* overrideStyle) const
-{
-    switch (overrideStyle ? overrideStyle->writingMode() : style()->writingMode()) {
-    case TopToBottomWritingMode:
-        return m_marginBottom;
-    case BottomToTopWritingMode:
-        return m_marginTop;
-    case LeftToRightWritingMode:
-        return m_marginRight;
-    case RightToLeftWritingMode:
-        return m_marginLeft;
-    }
-    ASSERT_NOT_REACHED();
-    return m_marginBottom;
-}
-
-LayoutUnit RenderBox::marginStart(const RenderStyle* overrideStyle) const
-{
-    const RenderStyle* styleToUse = overrideStyle ? overrideStyle : style();
-    if (styleToUse->isHorizontalWritingMode())
-        return styleToUse->isLeftToRightDirection() ? m_marginLeft : m_marginRight;
-    return styleToUse->isLeftToRightDirection() ? m_marginTop : m_marginBottom;
-}
-
-LayoutUnit RenderBox::marginEnd(const RenderStyle* overrideStyle) const
-{
-    const RenderStyle* styleToUse = overrideStyle ? overrideStyle : style();
-    if (styleToUse->isHorizontalWritingMode())
-        return styleToUse->isLeftToRightDirection() ? m_marginRight : m_marginLeft;
-    return styleToUse->isLeftToRightDirection() ? m_marginBottom : m_marginTop;
-}
-
-void RenderBox::setMarginStart(LayoutUnit margin, const RenderStyle* overrideStyle)
-{
-    const RenderStyle* styleToUse = overrideStyle ? overrideStyle : style();
-    if (styleToUse->isHorizontalWritingMode()) {
-        if (styleToUse->isLeftToRightDirection())
-            m_marginLeft = margin;
-        else
-            m_marginRight = margin;
-    } else {
-        if (styleToUse->isLeftToRightDirection())
-            m_marginTop = margin;
-        else
-            m_marginBottom = margin;
-    }
-}
-
-void RenderBox::setMarginEnd(LayoutUnit margin, const RenderStyle* overrideStyle)
-{
-    const RenderStyle* styleToUse = overrideStyle ? overrideStyle : style();
-    if (styleToUse->isHorizontalWritingMode()) {
-        if (styleToUse->isLeftToRightDirection())
-            m_marginRight = margin;
-        else
-            m_marginLeft = margin;
-    } else {
-        if (styleToUse->isLeftToRightDirection())
-            m_marginBottom = margin;
-        else
-            m_marginTop = margin;
-    }
-}
-
-void RenderBox::setMarginBefore(LayoutUnit margin, const RenderStyle* overrideStyle)
-{
-    switch (overrideStyle ? overrideStyle->writingMode() : style()->writingMode()) {
-    case TopToBottomWritingMode:
-        m_marginTop = margin;
-        break;
-    case BottomToTopWritingMode:
-        m_marginBottom = margin;
-        break;
-    case LeftToRightWritingMode:
-        m_marginLeft = margin;
-        break;
-    case RightToLeftWritingMode:
-        m_marginRight = margin;
-        break;
-    }
-}
-
-void RenderBox::setMarginAfter(LayoutUnit margin, const RenderStyle* overrideStyle)
-{
-    switch (overrideStyle ? overrideStyle->writingMode() : style()->writingMode()) {
-    case TopToBottomWritingMode:
-        m_marginBottom = margin;
-        break;
-    case BottomToTopWritingMode:
-        m_marginTop = margin;
-        break;
-    case LeftToRightWritingMode:
-        m_marginRight = margin;
-        break;
-    case RightToLeftWritingMode:
-        m_marginLeft = margin;
-        break;
-    }
-}
-
 LayoutRect RenderBox::borderBoxRectInRegion(RenderRegion* region, LayoutUnit offsetFromTopOfFirstPage, RenderBoxRegionInfoFlags cacheFlag) const
 {
     if (!region)
@@ -2591,8 +2471,8 @@
     const LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth();
     const Length marginLogicalLeft = isHorizontal ? style()->marginLeft() : style()->marginTop();
     const Length marginLogicalRight = isHorizontal ? style()->marginRight() : style()->marginBottom();
-    LayoutUnit& marginLogicalLeftAlias = isHorizontal ? m_marginLeft : m_marginTop;
-    LayoutUnit& marginLogicalRightAlias = isHorizontal ? m_marginRight : m_marginBottom;
+    LayoutUnit& marginLogicalLeftAlias = m_marginBox.mutableLogicalLeft(style());
+    LayoutUnit& marginLogicalRightAlias = m_marginBox.mutableLogicalRight(style());
 
     Length logicalLeftLength = style()->logicalLeft();
     Length logicalRightLength = style()->logicalRight();
@@ -2922,18 +2802,16 @@
 
     const LayoutUnit containerLogicalHeight = containingBlockLogicalHeightForPositioned(containerBlock);
 
-    bool isHorizontal = isHorizontalWritingMode();
     RenderStyle* styleToUse = style();
-    bool isFlipped = styleToUse->isFlippedBlocksWritingMode();
     const LayoutUnit bordersPlusPadding = borderAndPaddingLogicalHeight();
     const Length marginBefore = styleToUse->marginBefore();
     const Length marginAfter = styleToUse->marginAfter();
-    LayoutUnit& marginBeforeAlias = isHorizontal ? (isFlipped ? m_marginBottom : m_marginTop) : (isFlipped ? m_marginRight: m_marginLeft);
-    LayoutUnit& marginAfterAlias = isHorizontal ? (isFlipped ? m_marginTop : m_marginBottom) : (isFlipped ? m_marginLeft: m_marginRight);
+    LayoutUnit& marginBeforeAlias = m_marginBox.mutableBefore(styleToUse);
+    LayoutUnit& marginAfterAlias = m_marginBox.mutableAfter(styleToUse);
 
     Length logicalTopLength = styleToUse->logicalTop();
     Length logicalBottomLength = styleToUse->logicalBottom();
-        
+
     /*---------------------------------------------------------------------------*\
      * For the purposes of this section and the next, the term "static position"
      * (of an element) refers, roughly, to the position an element would have had
@@ -3190,8 +3068,8 @@
     Length logicalRight = style()->logicalRight();
     Length marginLogicalLeft = isHorizontal ? style()->marginLeft() : style()->marginTop();
     Length marginLogicalRight = isHorizontal ? style()->marginRight() : style()->marginBottom();
-    LayoutUnit& marginLogicalLeftAlias = isHorizontal ? m_marginLeft : m_marginTop;
-    LayoutUnit& marginLogicalRightAlias = isHorizontal ? m_marginRight : m_marginBottom;
+    LayoutUnit& marginLogicalLeftAlias = m_marginBox.mutableLogicalLeft(style());
+    LayoutUnit& marginLogicalRightAlias = m_marginBox.mutableLogicalRight(style());
 
     /*-----------------------------------------------------------------------*\
      * 1. The used value of 'width' is determined as for inline replaced
@@ -3349,12 +3227,10 @@
     const LayoutUnit containerLogicalHeight = containingBlockLogicalHeightForPositioned(containerBlock);
 
     // Variables to solve.
-    bool isHorizontal = isHorizontalWritingMode();
-    bool isFlipped = style()->isFlippedBlocksWritingMode();
     Length marginBefore = style()->marginBefore();
     Length marginAfter = style()->marginAfter();
-    LayoutUnit& marginBeforeAlias = isHorizontal ? (isFlipped ? m_marginBottom : m_marginTop) : (isFlipped ? m_marginRight: m_marginLeft);
-    LayoutUnit& marginAfterAlias = isHorizontal ? (isFlipped ? m_marginTop : m_marginBottom) : (isFlipped ? m_marginLeft: m_marginRight);
+    LayoutUnit& marginBeforeAlias = m_marginBox.mutableBefore(style());
+    LayoutUnit& marginAfterAlias = m_marginBox.mutableAfter(style());
 
     Length logicalTop = style()->logicalTop();
     Length logicalBottom = style()->logicalBottom();
@@ -3810,14 +3686,14 @@
 LayoutUnit RenderBox::lineHeight(bool /*firstLine*/, LineDirectionMode direction, LinePositionMode /*linePositionMode*/) const
 {
     if (isReplaced())
-        return direction == HorizontalLine ? m_marginTop + height() + m_marginBottom : m_marginRight + width() + m_marginLeft;
+        return direction == HorizontalLine ? m_marginBox.top() + height() + m_marginBox.bottom() : m_marginBox.right() + width() + m_marginBox.left();
     return 0;
 }
 
 LayoutUnit RenderBox::baselinePosition(FontBaseline baselineType, bool /*firstLine*/, LineDirectionMode direction, LinePositionMode /*linePositionMode*/) const
 {
     if (isReplaced()) {
-        LayoutUnit result = direction == HorizontalLine ? m_marginTop + height() + m_marginBottom : m_marginRight + width() + m_marginLeft;
+        LayoutUnit result = direction == HorizontalLine ? m_marginBox.top() + height() + m_marginBox.bottom() : m_marginBox.right() + width() + m_marginBox.left();
         if (baselineType == AlphabeticBaseline)
             return result;
         return result - result / 2;

Modified: trunk/Source/WebCore/rendering/RenderBox.h (118075 => 118076)


--- trunk/Source/WebCore/rendering/RenderBox.h	2012-05-22 22:58:53 UTC (rev 118075)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2012-05-22 23:05:33 UTC (rev 118076)
@@ -221,23 +221,27 @@
     virtual void setScrollLeft(int);
     virtual void setScrollTop(int);
 
-    virtual LayoutUnit marginTop() const { return m_marginTop; }
-    virtual LayoutUnit marginBottom() const { return m_marginBottom; }
-    virtual LayoutUnit marginLeft() const { return m_marginLeft; }
-    virtual LayoutUnit marginRight() const { return m_marginRight; }
-    void setMarginTop(LayoutUnit margin) { m_marginTop = margin; }
-    void setMarginBottom(LayoutUnit margin) { m_marginBottom = margin; }
-    void setMarginLeft(LayoutUnit margin) { m_marginLeft = margin; }
-    void setMarginRight(LayoutUnit margin) { m_marginRight = margin; }
-    virtual LayoutUnit marginBefore(const RenderStyle* overrideStyle = 0) const;
-    virtual LayoutUnit marginAfter(const RenderStyle* overrideStyle = 0) const;
-    virtual LayoutUnit marginStart(const RenderStyle* overrideStyle = 0) const;
-    virtual LayoutUnit marginEnd(const RenderStyle* overrideStyle = 0) const;
-    void setMarginStart(LayoutUnit, const RenderStyle* overrideStyle = 0);
-    void setMarginEnd(LayoutUnit, const RenderStyle* overrideStyle = 0);
-    void setMarginBefore(LayoutUnit, const RenderStyle* overrideStyle = 0);
-    void setMarginAfter(LayoutUnit, const RenderStyle* overrideStyle = 0);
+    virtual LayoutUnit marginTop() const OVERRIDE { return m_marginBox.top(); }
+    virtual LayoutUnit marginBottom() const OVERRIDE { return m_marginBox.bottom(); }
+    virtual LayoutUnit marginLeft() const OVERRIDE { return m_marginBox.left(); }
+    virtual LayoutUnit marginRight() const OVERRIDE { return m_marginBox.right(); }
+    void setMarginTop(LayoutUnit margin) { m_marginBox.setTop(margin); }
+    void setMarginBottom(LayoutUnit margin) { m_marginBox.setBottom(margin); }
+    void setMarginLeft(LayoutUnit margin) { m_marginBox.setLeft(margin); }
+    void setMarginRight(LayoutUnit margin) { m_marginBox.setRight(margin); }
 
+    virtual LayoutUnit marginLogicalLeft() const { return m_marginBox.logicalLeft(style()); }
+    virtual LayoutUnit marginLogicalRight() const { return m_marginBox.logicalRight(style()); }
+    
+    virtual LayoutUnit marginBefore(const RenderStyle* overrideStyle = 0) const OVERRIDE { return m_marginBox.before(overrideStyle ? overrideStyle : style()); }
+    virtual LayoutUnit marginAfter(const RenderStyle* overrideStyle = 0) const OVERRIDE { return m_marginBox.after(overrideStyle ? overrideStyle : style()); }
+    virtual LayoutUnit marginStart(const RenderStyle* overrideStyle = 0) const OVERRIDE { return m_marginBox.start(overrideStyle ? overrideStyle : style()); }
+    virtual LayoutUnit marginEnd(const RenderStyle* overrideStyle = 0) const OVERRIDE { return m_marginBox.end(overrideStyle ? overrideStyle : style()); }
+    void setMarginBefore(LayoutUnit value, const RenderStyle* overrideStyle = 0) { m_marginBox.setBefore(overrideStyle ? overrideStyle : style(), value); }
+    void setMarginAfter(LayoutUnit value, const RenderStyle* overrideStyle = 0) { m_marginBox.setAfter(overrideStyle ? overrideStyle : style(), value); }
+    void setMarginStart(LayoutUnit value, const RenderStyle* overrideStyle = 0) { m_marginBox.setStart(overrideStyle ? overrideStyle : style(), value); }
+    void setMarginEnd(LayoutUnit value, const RenderStyle* overrideStyle = 0) { m_marginBox.setEnd(overrideStyle ? overrideStyle : style(), value); }
+
     // The following five functions are used to implement collapsing margins.
     // All objects know their maximal positive and negative margins.  The
     // formula for computing a collapsed margin is |maxPosMargin| - |maxNegmargin|.
@@ -557,10 +561,7 @@
     LayoutRect m_frameRect;
 
 protected:
-    LayoutUnit m_marginLeft;
-    LayoutUnit m_marginRight;
-    LayoutUnit m_marginTop;
-    LayoutUnit m_marginBottom;
+    LayoutBoxExtent m_marginBox;
 
     // The preferred logical width of the element if it were to break its lines at every possible opportunity.
     LayoutUnit m_minPreferredLogicalWidth;

Modified: trunk/Source/WebCore/rendering/RenderScrollbarPart.cpp (118075 => 118076)


--- trunk/Source/WebCore/rendering/RenderScrollbarPart.cpp	2012-05-22 22:58:53 UTC (rev 118075)
+++ trunk/Source/WebCore/rendering/RenderScrollbarPart.cpp	2012-05-22 23:05:33 UTC (rev 118076)
@@ -98,8 +98,8 @@
     setWidth(max(minWidth, min(maxWidth, w)));
     
     // Buttons and track pieces can all have margins along the axis of the scrollbar. 
-    m_marginLeft = minimumValueForLength(style()->marginLeft(), visibleSize, renderView);
-    m_marginRight = minimumValueForLength(style()->marginRight(), visibleSize, renderView);
+    m_marginBox.setLeft(minimumValueForLength(style()->marginLeft(), visibleSize, renderView));
+    m_marginBox.setRight(minimumValueForLength(style()->marginRight(), visibleSize, renderView));
 }
 
 void RenderScrollbarPart::computeScrollbarHeight()
@@ -114,8 +114,8 @@
     setHeight(max(minHeight, min(maxHeight, h)));
 
     // Buttons and track pieces can all have margins along the axis of the scrollbar. 
-    m_marginTop = minimumValueForLength(style()->marginTop(), visibleSize, renderView);
-    m_marginBottom = minimumValueForLength(style()->marginBottom(), visibleSize, renderView);
+    m_marginBox.setTop(minimumValueForLength(style()->marginTop(), visibleSize, renderView));
+    m_marginBox.setBottom(minimumValueForLength(style()->marginBottom(), visibleSize, renderView));
 }
 
 void RenderScrollbarPart::computePreferredLogicalWidths()

Modified: trunk/Source/WebCore/rendering/RenderScrollbarPart.h (118075 => 118076)


--- trunk/Source/WebCore/rendering/RenderScrollbarPart.h	2012-05-22 22:58:53 UTC (rev 118075)
+++ trunk/Source/WebCore/rendering/RenderScrollbarPart.h	2012-05-22 23:05:33 UTC (rev 118076)
@@ -48,10 +48,10 @@
     void paintIntoRect(GraphicsContext*, const LayoutPoint&, const LayoutRect&);
 
     // Scrollbar parts needs to be rendered at device pixel boundaries.
-    virtual LayoutUnit marginTop() const { ASSERT(isIntegerValue(m_marginTop)); return m_marginTop; }
-    virtual LayoutUnit marginBottom() const { ASSERT(isIntegerValue(m_marginBottom)); return m_marginBottom; }
-    virtual LayoutUnit marginLeft() const { ASSERT(isIntegerValue(m_marginLeft)); return m_marginLeft; }
-    virtual LayoutUnit marginRight() const { ASSERT(isIntegerValue(m_marginRight)); return m_marginRight; }
+    virtual LayoutUnit marginTop() const OVERRIDE { ASSERT(isIntegerValue(m_marginBox.top())); return m_marginBox.top(); }
+    virtual LayoutUnit marginBottom() const OVERRIDE { ASSERT(isIntegerValue(m_marginBox.bottom())); return m_marginBox.bottom(); }
+    virtual LayoutUnit marginLeft() const OVERRIDE { ASSERT(isIntegerValue(m_marginBox.left())); return m_marginBox.left(); }
+    virtual LayoutUnit marginRight() const OVERRIDE { ASSERT(isIntegerValue(m_marginBox.right())); return m_marginBox.right(); }
 
     virtual bool isRenderScrollbarPart() const { return true; }
     RenderObject* rendererOwningScrollbar() const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to