Permalink
Browse files

Layout: adding display 'none'

  • Loading branch information...
paraboul committed Apr 20, 2017
1 parent 63543f6 commit a4fcc102904ad0d3f2004c053df455d07dd572b6
Showing with 26 additions and 14 deletions.
  1. +5 −5 src/Binding/JSCanvas.cpp
  2. +0 −1 src/Frontend/Context.cpp
  3. +0 −4 src/Graphics/CanvasHandler.cpp
  4. +21 −4 src/Graphics/CanvasHandler.h
@@ -902,13 +902,13 @@ bool JSCanvas::JSSetter_display(JSContext *cx, JS::MutableHandleValue vp)
}
JSAutoByteString cdisplay(cx, sdisplay);
if (strcmp("flex", cdisplay.ptr()) == 0) {
m_CanvasHandler->setPropFlex(true);
if (strcmp("none", cdisplay.ptr()) == 0) {
m_CanvasHandler->setPropDisplay(false);
return true;
}
m_CanvasHandler->setPropFlex(false);
m_CanvasHandler->setPropDisplay(true);
return true;
}
@@ -1180,13 +1180,13 @@ bool JSCanvas::JSGetter_minHeight(JSContext *cx, JS::MutableHandleValue vp)
bool JSCanvas::JSGetter_display(JSContext *cx, JS::MutableHandleValue vp)
{
if (m_CanvasHandler->getPropFlex()) {
if (m_CanvasHandler->getPropDisplay()) {
vp.setString(JS_NewStringCopyZ(cx, "flex"));
return true;
}
vp.setString(JS_NewStringCopyZ(cx, "default"));
vp.setString(JS_NewStringCopyZ(cx, "none"));
return true;
}
@@ -721,7 +721,6 @@ void Context::initHandlers(int width, int height)
m_RootHandler = new CanvasHandler(width, height, this);
m_RootHandler->setPositioning(CanvasHandler::COORD_RELATIVE);
m_RootHandler->p_Flex = false;
m_RootHandler->setContext(
new Canvas2DContext(m_RootHandler, width, height, m_UI));
@@ -75,8 +75,6 @@ CanvasHandler::CanvasHandler(float width,
memset(&m_MousePosition, 0, sizeof(m_MousePosition));
m_MousePosition.consumed = true;
//p_Flex = true;
m_Content.width = p_Width;
m_Content.height = p_Height;
@@ -85,8 +83,6 @@ CanvasHandler::CanvasHandler(float width,
m_Content.scrollLeft = 0;
m_Content.scrollTop = 0;
p_Flex = true;
}
void CanvasHandler::computeLayoutPositions()
@@ -207,9 +207,8 @@ class CanvasHandlerBase
CANVAS_DEF_CLASS_PROPERTY(MaxWidth, float, 0, State::kDefault);
CANVAS_DEF_CLASS_PROPERTY(MaxHeight, float, 0, State::kDefault);
CANVAS_DEF_CLASS_PROPERTY(Coating, float, 0, State::kDefault);
CANVAS_DEF_CLASS_PROPERTY(Flex, bool, false, State::kDefault);
CANVAS_DEF_CLASS_PROPERTY(EventReceiver,bool, true, State::kDefault);
CANVAS_DEF_CLASS_PROPERTY(Display, bool, true, State::kDefault);
CANVAS_DEF_CLASS_PROPERTY(Opacity, float, 1.0, State::kDefault);
@@ -321,8 +320,6 @@ class CanvasHandler : public CanvasHandlerBase, public Core::Events
bool consumed;
} m_MousePosition;
bool m_Overflow;
CanvasContext *getContext() const
{
return m_Context;
@@ -455,6 +452,13 @@ class CanvasHandler : public CanvasHandlerBase, public Core::Events
m_Padding.left = left;
}
void setPropDisplay(bool state) override
{
p_Display.set(state);
YGNodeStyleSetDisplay(m_YogaRef, state ? YGDisplayFlex : YGDisplayNone);
}
void setPropLeft(float val) override
{
p_Left.set(val);
@@ -499,6 +503,16 @@ class CanvasHandler : public CanvasHandlerBase, public Core::Events
}
}
void setOverflow(bool state) {
m_Overflow = state;
/* TODO: We should set YGOverflowScroll only if the view is scrollable */
YGNodeStyleSetOverflow(m_YogaRef, state ? YGOverflowScroll : YGOverflowVisible);
}
bool canOverflow() const {
return m_Overflow;
}
void setPropCoating(float value) override;
void setScale(double x, double y);
@@ -673,10 +687,13 @@ class CanvasHandler : public CanvasHandlerBase, public Core::Events
void recursiveScale(double x, double y, double oldX, double oldY);
bool m_Overflow;
bool m_Loaded;
int m_Cursor;
bool m_NeedPaint = true;
/* Reference to the Yoga node */
YGNodeRef m_YogaRef;
};

0 comments on commit a4fcc10

Please sign in to comment.