Title: [112742] trunk/Source/WebCore
Revision
112742
Author
[email protected]
Date
2012-03-30 16:27:51 -0700 (Fri, 30 Mar 2012)

Log Message

Add a compile assert for the size of BidiContext
https://bugs.webkit.org/show_bug.cgi?id=82793

Reviewed by Eric Seidel.

Added the assertion. Also reduced the number of bits used for bidi levels from
8 to 6 as done in InlineBox since bidi levels require exactly 6 bits.

* rendering/InlineBox.h: Added a comment about why bidi level needs exactly 6 bits.
* platform/text/BidiContext.cpp:
(SameSizeAsBidiContext):
(WebCore):
* platform/text/BidiContext.h:
(BidiContext):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (112741 => 112742)


--- trunk/Source/WebCore/ChangeLog	2012-03-30 23:26:53 UTC (rev 112741)
+++ trunk/Source/WebCore/ChangeLog	2012-03-30 23:27:51 UTC (rev 112742)
@@ -1,3 +1,20 @@
+2012-03-30  Ryosuke Niwa  <[email protected]>
+
+        Add a compile assert for the size of BidiContext
+        https://bugs.webkit.org/show_bug.cgi?id=82793
+
+        Reviewed by Eric Seidel.
+
+        Added the assertion. Also reduced the number of bits used for bidi levels from
+        8 to 6 as done in InlineBox since bidi levels require exactly 6 bits.
+
+        * rendering/InlineBox.h: Added a comment about why bidi level needs exactly 6 bits.
+        * platform/text/BidiContext.cpp:
+        (SameSizeAsBidiContext):
+        (WebCore):
+        * platform/text/BidiContext.h:
+        (BidiContext):
+
 2012-03-30  Joshua Bell  <[email protected]>
 
         IndexedDB: Race condition causes version change transaction to commit after onblocked

Modified: trunk/Source/WebCore/platform/text/BidiContext.cpp (112741 => 112742)


--- trunk/Source/WebCore/platform/text/BidiContext.cpp	2012-03-30 23:26:53 UTC (rev 112741)
+++ trunk/Source/WebCore/platform/text/BidiContext.cpp	2012-03-30 23:27:51 UTC (rev 112742)
@@ -27,6 +27,13 @@
 
 using namespace WTF::Unicode;
 
+struct SameSizeAsBidiContext : public RefCounted<SameSizeAsBidiContext> {
+    uint32_t bitfields : 16;
+    void* parent;
+};
+
+COMPILE_ASSERT(sizeof(BidiContext) == sizeof(SameSizeAsBidiContext), BidiContext_should_stay_small);
+
 inline PassRefPtr<BidiContext> BidiContext::createUncached(unsigned char level, Direction direction, bool override, BidiEmbeddingSource source, BidiContext* parent)
 {
     return adoptRef(new BidiContext(level, direction, override, source, parent));

Modified: trunk/Source/WebCore/platform/text/BidiContext.h (112741 => 112742)


--- trunk/Source/WebCore/platform/text/BidiContext.h	2012-03-30 23:26:53 UTC (rev 112741)
+++ trunk/Source/WebCore/platform/text/BidiContext.h	2012-03-30 23:27:51 UTC (rev 112742)
@@ -59,9 +59,9 @@
 
     static PassRefPtr<BidiContext> createUncached(unsigned char level, WTF::Unicode::Direction, bool override, BidiEmbeddingSource, BidiContext* parent);
 
-    unsigned char m_level;
+    unsigned m_level : 6; // The maximium bidi level is 62: http://unicode.org/reports/tr9/#Explicit_Levels_and_Directions
     unsigned m_direction : 5; // Direction
-    bool m_override : 1;
+    unsigned m_override : 1;
     unsigned m_source : 1; // BidiEmbeddingSource
     RefPtr<BidiContext> m_parent;
 };

Modified: trunk/Source/WebCore/rendering/InlineBox.h (112741 => 112742)


--- trunk/Source/WebCore/rendering/InlineBox.h	2012-03-30 23:26:53 UTC (rev 112741)
+++ trunk/Source/WebCore/rendering/InlineBox.h	2012-03-30 23:27:51 UTC (rev 112742)
@@ -342,7 +342,7 @@
         ADD_BOOLEAN_BITFIELD(constructed, Constructed);
 
     private:
-        unsigned m_bidiEmbeddingLevel : 6;
+        unsigned m_bidiEmbeddingLevel : 6; // The maximium bidi level is 62: http://unicode.org/reports/tr9/#Explicit_Levels_and_Directions
 
     public:
         unsigned char bidiEmbeddingLevel() const { return m_bidiEmbeddingLevel; }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to