Exemplo n.º 1
0
BOOL CALLBACK
CollectMonitors(HMONITOR aMon, HDC hDCScreen, LPRECT, LPARAM ioParam)
{
  auto screens = reinterpret_cast<nsTArray<RefPtr<Screen>>*>(ioParam);
  BOOL success = FALSE;
  MONITORINFO info;
  info.cbSize = sizeof(MONITORINFO);
  success = ::GetMonitorInfoW(aMon, &info);
  if (!success) {
    MOZ_LOG(sScreenLog, LogLevel::Error, ("GetMonitorInfoW failed"));
    return TRUE; // continue the enumeration
  }
  double scale = WinUtils::LogToPhysFactor(aMon);
  DesktopToLayoutDeviceScale contentsScaleFactor;
  if (WinUtils::IsPerMonitorDPIAware()) {
    contentsScaleFactor.scale = 1.0;
  } else {
    contentsScaleFactor.scale = scale;
  }
  CSSToLayoutDeviceScale defaultCssScaleFactor(scale);
  LayoutDeviceIntRect rect(info.rcMonitor.left, info.rcMonitor.top,
                           info.rcMonitor.right - info.rcMonitor.left,
                           info.rcMonitor.bottom - info.rcMonitor.top);
  LayoutDeviceIntRect availRect(info.rcWork.left, info.rcWork.top,
                                info.rcWork.right - info.rcWork.left,
                                info.rcWork.bottom - info.rcWork.top);
  uint32_t pixelDepth = ::GetDeviceCaps(hDCScreen, BITSPIXEL);
  if (pixelDepth == 32) {
    // If a device uses 32 bits per pixel, it's still only using 8 bits
    // per color component, which is what our callers want to know.
    // (Some devices report 32 and some devices report 24.)
    pixelDepth = 24;
  }
  float dpi = WinUtils::MonitorDPI(aMon);
  MOZ_LOG(sScreenLog, LogLevel::Debug,
           ("New screen [%d %d %d %d (%d %d %d %d) %d %f %f %f]",
            rect.X(), rect.Y(), rect.Width(), rect.Height(),
            availRect.X(), availRect.Y(), availRect.Width(), availRect.Height(),
            pixelDepth, contentsScaleFactor.scale, defaultCssScaleFactor.scale,
            dpi));
  auto screen = new Screen(rect, availRect,
                           pixelDepth, pixelDepth,
                           contentsScaleFactor, defaultCssScaleFactor,
                           dpi);
  if (info.dwFlags & MONITORINFOF_PRIMARY) {
    // The primary monitor must be the first element of the screen list.
    screens->InsertElementAt(0, Move(screen));
  } else {
    screens->AppendElement(Move(screen));
  }
  return TRUE;
}
/* nsIDOMSVGPathSeg insertItemBefore (in nsIDOMSVGPathSeg newItem, in unsigned long index); */
NS_IMETHODIMP nsSVGPathSegList::InsertItemBefore(nsIDOMSVGPathSeg *newItem,
                                                 PRUint32 index,
                                                 nsIDOMSVGPathSeg **_retval)
{
  NS_ENSURE_NATIVE_PATH_SEG(newItem, _retval);

  if (index >= static_cast<PRUint32>(mSegments.Count())) {
    return NS_ERROR_DOM_INDEX_SIZE_ERR;
  }

  InsertElementAt(static_cast<nsSVGPathSeg*>(newItem), index);
  NS_ADDREF(*_retval = newItem);

  return NS_OK;
}
Exemplo n.º 3
0
void
DMContainerMixin::HostElementSelf(
	DMElement*					inNewElement,
	const DM_DragPlacement*		inPlacement)
{

	// Validate pointers.

	ValidateThis_();
	ValidateObject_(inNewElement);
	
	// Add this element to our subelement list.
	
	InsertElementAt(inPlacement->mInsertionIndex, inNewElement, mIsSubObjectList);

}
/* nsIDOMSVGPathSeg replaceItem (in nsIDOMSVGPathSeg newItem, in unsigned long index); */
NS_IMETHODIMP nsSVGPathSegList::ReplaceItem(nsIDOMSVGPathSeg *newItem,
                                            PRUint32 index,
                                            nsIDOMSVGPathSeg **_retval)
{
  NS_ENSURE_NATIVE_PATH_SEG(newItem, _retval);

  // immediately remove the new item from its current list
  nsSVGPathSeg* newItemSeg = static_cast<nsSVGPathSeg*>(newItem);
  RemoveFromCurrentList(newItemSeg);

  if (index >= static_cast<PRUint32>(mSegments.Count())) {
    return NS_ERROR_DOM_INDEX_SIZE_ERR;
  }

  // NOTE: the new item can never be the item we will be replacing now that we removed it from its current list beforehand
  InsertElementAt(newItemSeg, index);
  RemoveFromCurrentList(static_cast<nsSVGPathSeg*>(mSegments.ObjectAt(index+1)));
  NS_ADDREF(*_retval = newItem);

  return NS_OK;
}
Exemplo n.º 5
0
void
DMListAttribute::ReadStreamData(
	LStream*		inStream,
	FourCharCode	inStreamSelector)
{

	// Validate pointers.

	ValidateThis_();

	// Check stream selector and include in stream flag.
	
	if ((inStreamSelector == mStreamSelector) && mInStream) {

		// Read item count.
		
		SInt32 count = 0;
		switch (mCountSize) {
			case 1:
				UInt8 count8;
				count8 = 0;
				*inStream >> count8;
				if (mZeroBasedCount && count8 == 255)
					count = -1;
				else
					count = count8;
				break;
			
			case 2:
				UInt16 count16;
				count16 = 0;
				*inStream >> count16;
				if (mZeroBasedCount && count16 == 65535)
					count = -1;
				else
					count = count16;
				break;
				
			case 4:
				*inStream >> count;
				break;
			
			default:
				SignalCStr_("mCountSize is invalid");

		}
		
		// Adjust count for zero-based count.
		
		if (mZeroBasedCount)
			count++;
		
		// Create this number of items.
		
		ValidateObject_(mPrototype.GetObject());

		while (count--) {
			InsertElementAt(LArray::index_Last, mPrototype->Clone(), true);
		}

		// Read their data.
		
		DMContainerAttribute::ReadStreamData(inStream, inStreamSelector);
		
	}