Title: [141588] trunk/Source
Revision
141588
Author
gga...@apple.com
Date
2013-02-01 07:01:34 -0800 (Fri, 01 Feb 2013)

Log Message

Added TriState to WTF and started using it in one place
https://bugs.webkit.org/show_bug.cgi?id=108628

Reviewed by Beth Dakin.

../_javascript_Core: 

* runtime/PrototypeMap.h:
(JSC::PrototypeMap::isPrototype): Use TriState instead of boolean. In
response to review feedback, this is an attempt to clarify that our
'true' condition is actually just a 'maybe'.

* runtime/PrototypeMap.h:
(PrototypeMap):
(JSC::PrototypeMap::isPrototype):

../WebCore: 

* editing/EditingStyle.h:
(WebCore): Moved TriState to WTF so it can be used in more places.

../WTF: 

Useful for expressing "maybe" conditions in a boolean context.

* WTF.xcodeproj/project.pbxproj:
* wtf/TriState.h: Added.
(WTF):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (141587 => 141588)


--- trunk/Source/_javascript_Core/ChangeLog	2013-02-01 14:17:49 UTC (rev 141587)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-02-01 15:01:34 UTC (rev 141588)
@@ -1,3 +1,19 @@
+2013-02-01  Geoffrey Garen  <gga...@apple.com>
+
+        Added TriState to WTF and started using it in one place
+        https://bugs.webkit.org/show_bug.cgi?id=108628
+
+        Reviewed by Beth Dakin.
+
+        * runtime/PrototypeMap.h:
+        (JSC::PrototypeMap::isPrototype): Use TriState instead of boolean. In
+        response to review feedback, this is an attempt to clarify that our
+        'true' condition is actually just a 'maybe'.
+
+        * runtime/PrototypeMap.h:
+        (PrototypeMap):
+        (JSC::PrototypeMap::isPrototype):
+
 2013-02-01  Alexis Menard  <ale...@webkit.org>
 
         Enable unprefixed CSS transitions by default.

Modified: trunk/Source/_javascript_Core/runtime/PrototypeMap.h (141587 => 141588)


--- trunk/Source/_javascript_Core/runtime/PrototypeMap.h	2013-02-01 14:17:49 UTC (rev 141587)
+++ trunk/Source/_javascript_Core/runtime/PrototypeMap.h	2013-02-01 15:01:34 UTC (rev 141588)
@@ -27,6 +27,7 @@
 #define PrototypeMap_h
 
 #include "WeakGCMap.h"
+#include <wtf/TriState.h>
 
 namespace JSC {
 
@@ -39,7 +40,7 @@
     JS_EXPORT_PRIVATE Structure* emptyObjectStructureForPrototype(JSObject*, unsigned inlineCapacity);
     void clearEmptyObjectStructureForPrototype(JSObject*, unsigned inlineCapacity);
     void addPrototype(JSObject*);
-    bool isPrototype(JSObject*); // Returns a conservative estimate.
+    TriState isPrototype(JSObject*) const; // Returns a conservative estimate.
 
 private:
     WeakGCMap<JSObject*, JSObject> m_prototypes;
@@ -47,9 +48,16 @@
     StructureMap m_structures;
 };
 
-inline bool PrototypeMap::isPrototype(JSObject* object)
+inline TriState PrototypeMap::isPrototype(JSObject* object) const
 {
-    return m_prototypes.contains(object);
+    if (!m_prototypes.contains(object))
+        return FalseTriState;
+
+    // We know that 'object' was used as a prototype at one time, so be
+    // conservative and say that it might still be so. (It would be expensive
+    // to find out for sure, and we don't know of any cases where being precise
+    // would improve performance.)
+    return MixedTriState;
 }
 
 } // namespace JSC

Modified: trunk/Source/WTF/ChangeLog (141587 => 141588)


--- trunk/Source/WTF/ChangeLog	2013-02-01 14:17:49 UTC (rev 141587)
+++ trunk/Source/WTF/ChangeLog	2013-02-01 15:01:34 UTC (rev 141588)
@@ -1,3 +1,16 @@
+2013-02-01  Geoffrey Garen  <gga...@apple.com>
+
+        Added TriState to WTF and started using it in one place
+        https://bugs.webkit.org/show_bug.cgi?id=108628
+
+        Reviewed by Beth Dakin.
+
+        Useful for expressing "maybe" conditions in a boolean context.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/TriState.h: Added.
+        (WTF):
+
 2013-02-01  Patrick Gansterer  <par...@webkit.org>
 
         Build fix for WinCE after r137709

Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (141587 => 141588)


--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2013-02-01 14:17:49 UTC (rev 141587)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2013-02-01 15:01:34 UTC (rev 141588)
@@ -32,6 +32,7 @@
 		0FDDBFA81666DFA300C55FEF /* StringPrintStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FDDBFA61666DFA300C55FEF /* StringPrintStream.h */; };
 		143F611F1565F0F900DB514A /* RAMSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 143F611D1565F0F900DB514A /* RAMSize.cpp */; };
 		143F61201565F0F900DB514A /* RAMSize.h in Headers */ = {isa = PBXBuildFile; fileRef = 143F611E1565F0F900DB514A /* RAMSize.h */; settings = {ATTRIBUTES = (); }; };
+		149EF16316BBFE0D000A4331 /* TriState.h in Headers */ = {isa = PBXBuildFile; fileRef = 149EF16216BBFE0D000A4331 /* TriState.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		14F3B0F715E45E4600210069 /* SaturatedArithmetic.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F3B0F615E45E4600210069 /* SaturatedArithmetic.h */; settings = {ATTRIBUTES = (); }; };
 		1A6BB769162F300500DD16DB /* StreamBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6BB768162F300500DD16DB /* StreamBuffer.h */; };
 		26147B0A15DDCCDC00DDB907 /* IntegerToStringConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 26147B0815DDCCDC00DDB907 /* IntegerToStringConversion.h */; };
@@ -310,7 +311,6 @@
 		F3FBC720161AF7CD00BB4BD4 /* MemoryInstrumentationSequence.h in Headers */ = {isa = PBXBuildFile; fileRef = F3FBC71F161AF7CD00BB4BD4 /* MemoryInstrumentationSequence.h */; };
 		FEDACD3D1630F83F00C69634 /* StackStats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDACD3B1630F83F00C69634 /* StackStats.cpp */; };
 		FEDACD3E1630F83F00C69634 /* StackStats.h in Headers */ = {isa = PBXBuildFile; fileRef = FEDACD3C1630F83F00C69634 /* StackStats.h */; };
-		FE43302716A7ADC300D1585D /* TypeSafeEnum.h in Headers */ = {isa = PBXBuildFile; fileRef = FE43302616A7ADC300D1585D /* TypeSafeEnum.h */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -335,6 +335,7 @@
 		0FDDBFA61666DFA300C55FEF /* StringPrintStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringPrintStream.h; sourceTree = "<group>"; };
 		143F611D1565F0F900DB514A /* RAMSize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RAMSize.cpp; sourceTree = "<group>"; };
 		143F611E1565F0F900DB514A /* RAMSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RAMSize.h; sourceTree = "<group>"; };
+		149EF16216BBFE0D000A4331 /* TriState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriState.h; sourceTree = "<group>"; };
 		14F3B0F615E45E4600210069 /* SaturatedArithmetic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaturatedArithmetic.h; sourceTree = "<group>"; };
 		1A6BB768162F300500DD16DB /* StreamBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamBuffer.h; sourceTree = "<group>"; };
 		26147B0815DDCCDC00DDB907 /* IntegerToStringConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntegerToStringConversion.h; sourceTree = "<group>"; };
@@ -623,7 +624,6 @@
 		F3FBC71F161AF7CD00BB4BD4 /* MemoryInstrumentationSequence.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryInstrumentationSequence.h; sourceTree = "<group>"; };
 		FEDACD3B1630F83F00C69634 /* StackStats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackStats.cpp; sourceTree = "<group>"; };
 		FEDACD3C1630F83F00C69634 /* StackStats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackStats.h; sourceTree = "<group>"; };
-		FE43302616A7ADC300D1585D /* TypeSafeEnum.h */ = {isa = PBXFileReference; fileEncoding = 4; path = TypeSafeEnum.h; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -869,8 +869,8 @@
 				A8A47338151A825B004123FF /* ThreadRestrictionVerifier.h */,
 				A8A4733E151A825B004123FF /* ThreadSafeRefCounted.h */,
 				A8A4733F151A825B004123FF /* ThreadSpecific.h */,
+				149EF16216BBFE0D000A4331 /* TriState.h */,
 				A8A47341151A825B004123FF /* TypedArrayBase.h */,
-				FE43302616A7ADC300D1585D /* TypeSafeEnum.h */,
 				A8A47342151A825B004123FF /* TypeTraits.cpp */,
 				A8A47343151A825B004123FF /* TypeTraits.h */,
 				A8A47346151A825B004123FF /* Uint16Array.h */,
@@ -1229,7 +1229,6 @@
 				A8A47454151A825B004123FF /* ThreadSafeRefCounted.h in Headers */,
 				A8A47455151A825B004123FF /* ThreadSpecific.h in Headers */,
 				A8A47457151A825B004123FF /* TypedArrayBase.h in Headers */,
-				FE43302716A7ADC300D1585D /* TypeSafeEnum.h in Headers */,
 				A8A47459151A825B004123FF /* TypeTraits.h in Headers */,
 				A8A4745C151A825B004123FF /* Uint16Array.h in Headers */,
 				A8A4745D151A825B004123FF /* Uint32Array.h in Headers */,
@@ -1262,6 +1261,7 @@
 				974CFC8E16A4F327006D5404 /* WeakPtr.h in Headers */,
 				A8A47446151A825B004123FF /* WTFString.h in Headers */,
 				A8A47487151A825B004123FF /* WTFThreadData.h in Headers */,
+				149EF16316BBFE0D000A4331 /* TriState.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: trunk/Source/WTF/wtf/TriState.h (0 => 141588)


--- trunk/Source/WTF/wtf/TriState.h	                        (rev 0)
+++ trunk/Source/WTF/wtf/TriState.h	2013-02-01 15:01:34 UTC (rev 141588)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 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. ``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
+ * 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 TriState_h
+#define TriState_h
+
+namespace WTF {
+
+enum TriState {
+    FalseTriState,
+    TrueTriState,
+    MixedTriState
+};
+
+}
+
+using WTF::TriState;
+using WTF::FalseTriState;
+using WTF::TrueTriState;
+using WTF::MixedTriState;
+
+#endif // TriState_h

Modified: trunk/Source/WebCore/ChangeLog (141587 => 141588)


--- trunk/Source/WebCore/ChangeLog	2013-02-01 14:17:49 UTC (rev 141587)
+++ trunk/Source/WebCore/ChangeLog	2013-02-01 15:01:34 UTC (rev 141588)
@@ -1,3 +1,13 @@
+2013-02-01  Geoffrey Garen  <gga...@apple.com>
+
+        Added TriState to WTF and started using it in one place
+        https://bugs.webkit.org/show_bug.cgi?id=108628
+
+        Reviewed by Beth Dakin.
+
+        * editing/EditingStyle.h:
+        (WebCore): Moved TriState to WTF so it can be used in more places.
+
 2013-02-01  Pavel Feldman  <pfeld...@chromium.org>
 
         Web Inspector: Follow up to r141260: fixing renamed style.

Modified: trunk/Source/WebCore/editing/EditingStyle.h (141587 => 141588)


--- trunk/Source/WebCore/editing/EditingStyle.h	2013-02-01 14:17:49 UTC (rev 141587)
+++ trunk/Source/WebCore/editing/EditingStyle.h	2013-02-01 15:01:34 UTC (rev 141588)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 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
@@ -36,6 +37,7 @@
 #include <wtf/Forward.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
+#include <wtf/TriState.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
@@ -56,8 +58,6 @@
 class StyledElement;
 class VisibleSelection;
 
-enum TriState { FalseTriState, TrueTriState, MixedTriState };
-
 class EditingStyle : public RefCounted<EditingStyle> {
 public:
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to