Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1632)

Unified Diff: Source/core/rendering/style/GridResolvedPosition.h

Issue 113943003: [CSS Grid] Introduce an explicit type for resolved grid positions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@to-land-zero
Patch Set: Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/style/GridPosition.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/style/GridResolvedPosition.h
diff --git a/Source/bindings/v8/ScriptPromise.h b/Source/core/rendering/style/GridResolvedPosition.h
similarity index 51%
copy from Source/bindings/v8/ScriptPromise.h
copy to Source/core/rendering/style/GridResolvedPosition.h
index 0a93b10f3b4001fd2ca2ef99e765076c82c3c2f1..39c4a4052083f159e77b5780d0fc419ee4a1fb0c 100644
--- a/Source/bindings/v8/ScriptPromise.h
+++ b/Source/core/rendering/style/GridResolvedPosition.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2012 Igalia S.L. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,86 +28,77 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef ScriptPromise_h
-#define ScriptPromise_h
+#ifndef GridResolvedPosition_h
+#define GridResolvedPosition_h
-#include "bindings/v8/ScopedPersistent.h"
-#include "bindings/v8/ScriptValue.h"
-#include "bindings/v8/V8ScriptRunner.h"
-#include <v8.h>
+#include "core/rendering/style/GridPosition.h"
namespace WebCore {
-class ExecutionContext;
+enum GridPositionSide {
+ ColumnStartSide,
+ ColumnEndSide,
+ RowStartSide,
+ RowEndSide
+};
-// ScriptPromise is the class for representing Promise values in C++ world.
-// ScriptPromise holds a Promise.
-// So holding a ScriptPromise as a member variable in DOM object causes
-// memory leaks since it has a reference from C++ to V8.
-//
-class ScriptPromise {
+class GridResolvedPosition {
public:
- // Constructs an empty promise.
- ScriptPromise()
- : m_promise()
+ static size_t adjustGridPositionForAfterEndSide(size_t resolvedPosition)
{
+ return resolvedPosition ? resolvedPosition - 1 : 0;
}
- explicit ScriptPromise(const ScriptValue& promise)
- : m_promise(promise)
+ static size_t adjustGridPositionForSide(size_t resolvedPosition, GridPositionSide side)
{
- ASSERT(!m_promise.hasNoValue());
- }
+ // An item finishing on the N-th line belongs to the N-1-th cell.
+ if (side == ColumnEndSide || side == RowEndSide)
+ return adjustGridPositionForAfterEndSide(resolvedPosition);
- ScriptPromise(v8::Handle<v8::Value> promise, v8::Isolate* isolate)
- : m_promise(promise, isolate)
- {
- ASSERT(!m_promise.hasNoValue());
+ return resolvedPosition;
}
- bool isObject() const
+ GridResolvedPosition()
+ : m_integerPosition(0)
{
- return m_promise.isObject();
}
- bool isNull() const
+ GridResolvedPosition(size_t position)
+ : m_integerPosition(position)
{
- return m_promise.isNull();
}
- bool isUndefinedOrNull() const
+ GridResolvedPosition(const GridPosition& position, GridPositionSide side)
{
- return m_promise.isUndefined() || m_promise.isNull();
- }
+ size_t integerPosition;
- v8::Handle<v8::Value> v8Value() const
- {
- return m_promise.v8Value();
+ ASSERT(position.integerPosition());
+ integerPosition = position.integerPosition() - 1;
+
+ m_integerPosition = adjustGridPositionForSide(integerPosition, side);
}
- v8::Isolate* isolate() const
+ size_t integerPosition() const
{
- return m_promise.isolate();
+ return m_integerPosition;
}
- bool hasNoValue() const
+ void setIntegerPosition(size_t position)
{
- return m_promise.hasNoValue();
+ m_integerPosition = position;
}
- void clear()
+ bool operator==(const GridResolvedPosition& other) const
{
- m_promise.clear();
+ return m_integerPosition == other.m_integerPosition;
}
- static ScriptPromise createPending();
- static ScriptPromise createPending(ExecutionContext*);
+operator int() const { return m_integerPosition; }
private:
- ScriptValue m_promise;
+ size_t m_integerPosition;
};
} // namespace WebCore
-
-#endif // ScriptPromise_h
+#endif // GridResolvedPosition_h
« no previous file with comments | « Source/core/rendering/style/GridPosition.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698