コード例 #1
0
nsCollapsingMargin
nsLineBox::GetCarriedOutBottomMargin() const
{
  NS_ASSERTION(IsBlock(),
               "GetCarriedOutBottomMargin called on non-block line.");
  return (IsBlock() && mBlockData)
    ? mBlockData->mCarriedOutBottomMargin
    : nsCollapsingMargin();
}
コード例 #2
0
ファイル: syntax.cpp プロジェクト: c3d/elfe
bool Syntax::IsBlock(char Begin, text &End)
// ----------------------------------------------------------------------------
//   Return true if we are looking at a block
// ----------------------------------------------------------------------------
{
    return IsBlock(text(&Begin, 1), End);
}
コード例 #3
0
    SOCKET_RESULT_CODE Connect(struct sockaddr* server, int socketLen, int msTimeout) {
        SOCKET_RESULT_CODE result = SOCKET_RESULT_FAIL;
        
        if (INVALID_SOCKET != m_socket )
        {
			// 获取当前block状态
			bool block = IsBlock();

			SetBlock(true);

            m_connStatus = CONNECTION_STATUS_CONNECTING;
			if( msTimeout > 0 ) {
                timeval timeout;
                timeout.tv_sec = msTimeout / 1000;
                timeout.tv_usec = msTimeout % 1000;
                socklen_t len = sizeof(timeout);
                setsockopt(m_socket, SOL_SOCKET, SO_SNDTIMEO, &timeout, len);
            }

            if (connect(m_socket, (struct sockaddr*)server, socketLen) == 0) {
                result = SOCKET_RESULT_SUCCESS;
            }

            if (SOCKET_RESULT_SUCCESS == result) {
                m_connStatus = CONNECTION_STATUS_CONNECTED;
            }
            else {
                m_connStatus = CONNECTION_STATUS_DISCONNECT;
            }
            
            // 回复block状态
			SetBlock(block);
        }
        return result;
    }
コード例 #4
0
ファイル: LoginDlg.cpp プロジェクト: 0anion0/IBN
void CLoginDlg::OnClickButtonCancel()
{
    //Cancel Operation ...
    if(IsBlock())
    {
        if(::IsWindow(GetParent()->GetSafeHwnd()))
            GetParent()->PostMessage(WM_CANCELLOGIN,0,0);
    }
}
コード例 #5
0
void
nsLineBox::Cleanup()
{
  if (mData) {
    if (IsBlock()) {
      delete mBlockData;
    }
    else {
      delete mInlineData;
    }
    mData = nullptr;
  }
}
コード例 #6
0
ファイル: LoginDlg.cpp プロジェクト: 0anion0/IBN
void CLoginDlg::OnClose()
{
    if(!IsBlock())
    {
        if(GetStyle()&WS_VISIBLE&&GetOptionInt(IDS_OFSMESSENGER,IDS_ANIMATION,FALSE))
            RoundExitAddon(this);
        // TODO: Add your message handler code here and/or call default
        if(IsWindow(GetParent()->GetSafeHwnd()))
            GetParent()->PostMessage(WM_CLOSE);
        COFSNcDlg2::OnClose();

    }
}
コード例 #7
0
char*
nsLineBox::StateToString(char* aBuf, PRInt32 aBufSize) const
{
  PR_snprintf(aBuf, aBufSize, "%s,%s,%s,%s,%s,before:%s,after:%s[0x%x]",
              IsBlock() ? "block" : "inline",
              IsDirty() ? "dirty" : "clean",
              IsPreviousMarginDirty() ? "prevmargindirty" : "prevmarginclean",
              IsImpactedByFloat() ? "impacted" : "not impacted",
              IsLineWrapped() ? "wrapped" : "not wrapped",
              BreakTypeToString(GetBreakTypeBefore()),
              BreakTypeToString(GetBreakTypeAfter()),
              mAllFlags);
  return aBuf;
}
コード例 #8
0
void
nsLineBox::List(FILE* out, PRInt32 aIndent) const
{
  PRInt32 i;

  for (i = aIndent; --i >= 0; ) fputs("  ", out);
  char cbuf[100];
  fprintf(out, "line %p: count=%d state=%s ",
          static_cast<const void*>(this), GetChildCount(),
          StateToString(cbuf, sizeof(cbuf)));
  if (IsBlock() && !GetCarriedOutBottomMargin().IsZero()) {
    fprintf(out, "bm=%d ", GetCarriedOutBottomMargin().get());
  }
  fprintf(out, "{%d,%d,%d,%d} ",
          mBounds.x, mBounds.y, mBounds.width, mBounds.height);
  if (mData) {
    fprintf(out, "vis-overflow={%d,%d,%d,%d} scr-overflow={%d,%d,%d,%d} ",
            mData->mOverflowAreas.VisualOverflow().x,
            mData->mOverflowAreas.VisualOverflow().y,
            mData->mOverflowAreas.VisualOverflow().width,
            mData->mOverflowAreas.VisualOverflow().height,
            mData->mOverflowAreas.ScrollableOverflow().x,
            mData->mOverflowAreas.ScrollableOverflow().y,
            mData->mOverflowAreas.ScrollableOverflow().width,
            mData->mOverflowAreas.ScrollableOverflow().height);
  }
  fprintf(out, "<\n");

  nsIFrame* frame = mFirstChild;
  PRInt32 n = GetChildCount();
  while (--n >= 0) {
    frame->List(out, aIndent + 1);
    frame = frame->GetNextSibling();
  }

  for (i = aIndent; --i >= 0; ) fputs("  ", out);
  if (HasFloats()) {
    fputs("> floats <\n", out);
    ListFloats(out, aIndent + 1, mInlineData->mFloats);
    for (i = aIndent; --i >= 0; ) fputs("  ", out);
  }
  fputs(">\n", out);
}
コード例 #9
0
ファイル: nsLineBox.cpp プロジェクト: BrunoReX/palemoon
void
nsLineBox::List(FILE* out, int32_t aIndent, uint32_t aFlags) const
{
  nsFrame::IndentBy(out, aIndent);
  char cbuf[100];
  fprintf(out, "line %p: count=%d state=%s ",
          static_cast<const void*>(this), GetChildCount(),
          StateToString(cbuf, sizeof(cbuf)));
  if (IsBlock() && !GetCarriedOutBottomMargin().IsZero()) {
    fprintf(out, "bm=%d ", GetCarriedOutBottomMargin().get());
  }
  fprintf(out, "{%d,%d,%d,%d} ",
          mBounds.x, mBounds.y, mBounds.width, mBounds.height);
  if (mData &&
      (!mData->mOverflowAreas.VisualOverflow().IsEqualEdges(mBounds) ||
       !mData->mOverflowAreas.ScrollableOverflow().IsEqualEdges(mBounds))) {
    fprintf(out, "vis-overflow=%d,%d,%d,%d scr-overflow=%d,%d,%d,%d ",
            mData->mOverflowAreas.VisualOverflow().x,
            mData->mOverflowAreas.VisualOverflow().y,
            mData->mOverflowAreas.VisualOverflow().width,
            mData->mOverflowAreas.VisualOverflow().height,
            mData->mOverflowAreas.ScrollableOverflow().x,
            mData->mOverflowAreas.ScrollableOverflow().y,
            mData->mOverflowAreas.ScrollableOverflow().width,
            mData->mOverflowAreas.ScrollableOverflow().height);
  }
  fprintf(out, "<\n");

  nsIFrame* frame = mFirstChild;
  int32_t n = GetChildCount();
  while (--n >= 0) {
    frame->List(out, aIndent + 1, aFlags);
    frame = frame->GetNextSibling();
  }

  if (HasFloats()) {
    nsFrame::IndentBy(out, aIndent);
    fputs("> floats <\n", out);
    ListFloats(out, aIndent + 1, mInlineData->mFloats);
  }
  nsFrame::IndentBy(out, aIndent);
  fputs(">\n", out);
}
コード例 #10
0
bool
nsLineBox::SetCarriedOutBottomMargin(nsCollapsingMargin aValue)
{
  bool changed = false;
  if (IsBlock()) {
    if (!aValue.IsZero()) {
      if (!mBlockData) {
        mBlockData = new ExtraBlockData(mBounds);
      }
      changed = aValue != mBlockData->mCarriedOutBottomMargin;
      mBlockData->mCarriedOutBottomMargin = aValue;
    }
    else if (mBlockData) {
      changed = aValue != mBlockData->mCarriedOutBottomMargin;
      mBlockData->mCarriedOutBottomMargin = aValue;
      MaybeFreeData();
    }
  }
  return changed;
}
コード例 #11
0
bool
nsLineBox::IsEmpty() const
{
  if (IsBlock())
    return mFirstChild->IsEmpty();

  PRInt32 n;
  nsIFrame *kid;
  for (n = GetChildCount(), kid = mFirstChild;
       n > 0;
       --n, kid = kid->GetNextSibling())
  {
    if (!kid->IsEmpty())
      return false;
  }
  if (HasBullet()) {
    return false;
  }
  return true;
}
コード例 #12
0
	// 发送
	virtual HANDLE_RESULT Send(void* data, unsigned int dataLen)
	{
		HANDLE_RESULT result = HANDLE_FAIL;

		if (INVALID_SOCKET != m_socket)
		{
			if ( IsBlock() )
			{
				// blocking send
				int total = 0;
				while (true) {
					int iSent = send(m_socket, (const char*)data, dataLen, 0);
					if (iSent > 0) {
						total += iSent;
					}
					else {
						break;
					}

					if (total == dataLen) {
						result = HANDLE_SUCCESS;
						break;
					}
				}
			}
			else
			{
				// non blocking send
				int iSent = send(m_socket, (const char*)data, dataLen, 0);
				if (iSent > 0
					|| (iSent < 0 && (EWOULDBLOCK == errno || EINTR == errno)))
				{
					result = HANDLE_SUCCESS;
				}
			}
		}
		return result;
	}
コード例 #13
0
ファイル: ProcessParameter.cpp プロジェクト: SunGong1993/PCL
ProcessParameter::data_type ProcessParameter::DataInterpretation() const
{
   if ( !IsBlock() )
      return ProcessParameterType::Invalid;

   uint32 apiType = (*API->Process->GetParameterType)( m_data->handle );
   if ( apiType == 0 )
      throw APIFunctionError( "GetParameterType" );

   switch ( apiType & PTYPE_BLOCK_INTERPRETATION )
   {
   case PTYPE_BLOCK_UI8:    return ProcessParameterType::UInt8;
   case PTYPE_BLOCK_I8:     return ProcessParameterType::Int8;
   case PTYPE_BLOCK_UI16:   return ProcessParameterType::UInt16;
   case PTYPE_BLOCK_I16:    return ProcessParameterType::Int16;
   case PTYPE_BLOCK_UI32:   return ProcessParameterType::UInt32;
   case PTYPE_BLOCK_I32:    return ProcessParameterType::Int32;
   case PTYPE_BLOCK_UI64:   return ProcessParameterType::UInt64;
   case PTYPE_BLOCK_I64:    return ProcessParameterType::Int64;
   case PTYPE_BLOCK_FLOAT:  return ProcessParameterType::Float;
   case PTYPE_BLOCK_DOUBLE: return ProcessParameterType::Double;
   default:                 throw Error( "ProcessParameter::DataInterpretation(): Internal error: Unknown parameter type" );
   }
}
コード例 #14
0
bool
nsLineBox::CachedIsEmpty()
{
  if (mFlags.mDirty) {
    return IsEmpty();
  }
  
  if (mFlags.mEmptyCacheValid) {
    return mFlags.mEmptyCacheState;
  }

  bool result;
  if (IsBlock()) {
    result = mFirstChild->CachedIsEmpty();
  } else {
    PRInt32 n;
    nsIFrame *kid;
    result = true;
    for (n = GetChildCount(), kid = mFirstChild;
         n > 0;
         --n, kid = kid->GetNextSibling())
      {
        if (!kid->CachedIsEmpty()) {
          result = false;
          break;
        }
      }
    if (HasBullet()) {
      result = false;
    }
  }

  mFlags.mEmptyCacheValid = true;
  mFlags.mEmptyCacheState = result;
  return result;
}
コード例 #15
0
ファイル: LoginDlg.cpp プロジェクト: 0anion0/IBN
void CLoginDlg::OnOK()
{
    if(!IsBlock())
        OnClickButtonLogin();
}
コード例 #16
0
	// 连接(msTimeout:超时时间(毫秒),不大于0表示使用默认超时)
	virtual SOCKET_RESULT_CODE Connect(const string& ip, unsigned int port, int msTimeout)
	{
		FileLog("RtmpClient",
				"ISocketHandler::Connect( "
				"m_socket : %d, "
				"ip : %s, "
				"port : %d, "
				"msTimeout : %d "
				")",
				m_socket,
				ip.c_str(),
				port,
				msTimeout
				);

		SOCKET_RESULT_CODE result = SOCKET_RESULT_FAIL;

		// 定义socketaddr
		sockaddr_in server;
		bzero(&server, sizeof(server));
		server.sin_family = AF_INET;
		server.sin_port = htons(port);

		if (INVALID_SOCKET != m_socket
			&& !(inet_pton(AF_INET, ip.c_str(), &server.sin_addr) < 0))
		{
			// 获取当前block状态
			bool block = IsBlock();

			SetBlock(true);

            m_connStatus = CONNECTION_STATUS_CONNECTING;
			if( msTimeout > 0 ) {
                timeval timeout;
                timeout.tv_sec = msTimeout / 1000;
                timeout.tv_usec = msTimeout % 1000;
                socklen_t len = sizeof(timeout);
                setsockopt(m_socket, SOL_SOCKET, SO_SNDTIMEO, &timeout, len);
            }

			if (connect(m_socket, (struct sockaddr*)&server, sizeof(sockaddr_in)) == 0) {
				result = SOCKET_RESULT_SUCCESS;
			}

            if (SOCKET_RESULT_SUCCESS == result) {
                m_connStatus = CONNECTION_STATUS_CONNECTED;
            }
            else {
                m_connStatus = CONNECTION_STATUS_DISCONNECT;
            }

			// 回复block状态
			SetBlock(block);
		}

		if( result == SOCKET_RESULT_SUCCESS ) {
			sockaddr_in client;
			socklen_t client_len = sizeof(client);
			getsockname(m_socket, (struct sockaddr*)&client, &client_len);
			this->port = ntohs(client.sin_port);
		}

		FileLog("RtmpClient",
				"ISocketHandler::Connect( "
				"connect finish "
				"m_socket : %d, "
				"result : %d, "
				"errno : %d "
				")",
				m_socket,
				result,
				errno
				);

		return result;
	}
コード例 #17
0
	// 接收
	virtual HANDLE_RESULT Recv(void* data, unsigned int dataSize, unsigned int& dataLen)
	{
		HANDLE_RESULT result = HANDLE_FAIL;

		if (INVALID_SOCKET != m_socket)
		{
			if ( IsBlock() )
			{
				// blocking receive
				int length = 0;
				dataLen = 0;
//				FileLog("RtmpClient",
//						"ISocketHandler::Recv( "
//						"dataSize : %d "
//						")",
//						dataSize
//						);

				while( dataLen < dataSize ) {
					length = recv(m_socket, (char*)data + dataLen, dataSize - dataLen, 0);
					if( length > 0 ) {
//						string str = Arithmetic::AsciiToHexWithSep(data + dataLen, length);
//						FileLog("RtmpClient",
//								"ISocketHandler::Recv( "
//								"str : %s "
//								")",
//								str.c_str()
//								);

						dataLen += length;
//						FileLog("RtmpClient",
//								"ISocketHandler::Recv( "
//								"length : %d, "
//								"dataLen : %d, "
//								"dataSize : %d "
//								")",
//								length,
//								dataLen,
//								dataSize
//								);
					} else {
//						// 接收失败
//						FileLog("CamshareClient",
//								"ISocketHandler::Recv( "
//								"break, "
//								"length : %d "
//								")",
//								length
//								);

						break;
					}
				}

				// 接收足够数据才算成功
				if ( dataLen == dataSize ) {
					result = HANDLE_SUCCESS;
				}
			}
			else
			{
				// non blocking receive

				// 初始化超时时间(300ms)
				unsigned int uiTimeout = 300;
				// 初始化超时时间
				timeval tout;
				tout.tv_sec = uiTimeout / 1000;
				tout.tv_usec = (uiTimeout % 1000) * 1000;

				// 初始化fd_set
				fd_set rset;
				FD_ZERO(&rset);
				FD_SET(m_socket, &rset);
				int iRetS = select(m_socket + 1, &rset, NULL, NULL, &tout);

				if (iRetS == 0) {
					// 超时
					result = HANDLE_TIMEOUT;
				}
	            else if (iRetS > 0)
	            {
	            	// 有数据可以接收
	                int iRet = recv(m_socket, data, dataLen, 0);
					if (iRet > 0)
					{
						result = HANDLE_SUCCESS;
					}
					else if (iRet <= 0
							&& (EWOULDBLOCK == errno || EINTR == errno))
					{
						result = HANDLE_TIMEOUT;
					}
	            }
			}
		}

		return result;
	}
コード例 #18
0
	// 接收
	virtual HANDLE_RESULT Recv(void* data, unsigned int dataSize, unsigned int& dataLen, bool bRecvAll)
	{
		HANDLE_RESULT result = HANDLE_FAIL;

		if (INVALID_SOCKET != m_socket)
		{
			if ( IsBlock() )
			{
				// blocking receive
				int length = 0;
				dataLen = 0;
				while( dataLen < dataSize ) {
					length = recv(m_socket, (char*)data + dataLen, dataSize - dataLen, 0);
                    if (length > 0) {
                        dataLen += length;
                        if( !bRecvAll ) {
                            // 如果不需要全部接收, 直接返回
                            break;
                        }
                    } else {
                        break;
                    }
                }
                
				if ( (bRecvAll && (dataLen == dataSize)) || (!bRecvAll && dataLen > 0) ) {
                    // 1.标记为全部接收并且接收足够数据
                    // 2.没有标记全部接收并且接收到数据
					result = HANDLE_SUCCESS;
                }
			}
			else
			{
				// non blocking receive

				// 初始化超时时间(300ms)
				unsigned int uiTimeout = 300;
				// 初始化超时时间
				timeval tout;
				tout.tv_sec = uiTimeout / 1000;
				tout.tv_usec = (uiTimeout % 1000) * 1000;

				// 初始化fd_set
				fd_set rset;
				FD_ZERO(&rset);
				FD_SET(m_socket, &rset);
				int iRetS = select(m_socket + 1, &rset, NULL, NULL, &tout);

				//FileLog("LiveChatClient", "ISocketHandler::Recv() iRetS:%d", iRetS);

				if (iRetS == 0) {
					// 超时
					result = HANDLE_TIMEOUT;
				}
	            else if (iRetS > 0)
	            {
	            	// 有数据可以接收
	                int iRet = recv(m_socket, data, dataLen, 0);
	                //FileLog("LiveChatClient", "ISocketHandler::Recv() iRet:%d", iRet);
					if (iRet > 0)
					{
						result = HANDLE_SUCCESS;
					}
					else if (iRet <= 0
							&& (EWOULDBLOCK == errno || EINTR == errno))
					{
						result = HANDLE_TIMEOUT;
					}
	            }
			}
		}

		return result;
	}