Esempio n. 1
0
void
TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
                       uint32_t* aStartOffset, uint32_t* aEndOffset)
{
  // Navigate backward from anchor accessible to find start offset.
  for (int32_t childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) {
    Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);

    // Stop on embedded accessible since embedded accessibles are combined into
    // own range.
    if (!currAcc->IsText())
      break;

    MOZ_ASSERT(nsCoreUtils::GetDOMElementFor(currAcc->GetContent()),
               "Text accessible has to have an associated DOM element");

    bool offsetFound = false;
    for (uint32_t attrIdx = 0; attrIdx < aAttrArrayLen; attrIdx++) {
      TextAttr* textAttr = aAttrArray[attrIdx];
      if (!textAttr->Equal(currAcc)) {
        offsetFound = true;
        break;
      }
    }

    if (offsetFound)
      break;

    *(aStartOffset) -= nsAccUtils::TextLength(currAcc);
  }

  // Navigate forward from anchor accessible to find end offset.
  uint32_t childLen = mHyperTextAcc->ChildCount();
  for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childLen; childIdx++) {
    Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
    if (!currAcc->IsText())
      break;

    MOZ_ASSERT(nsCoreUtils::GetDOMElementFor(currAcc->GetContent()),
               "Text accessible has to have an associated DOM element");

    bool offsetFound = false;
    for (uint32_t attrIdx = 0; attrIdx < aAttrArrayLen; attrIdx++) {
      TextAttr* textAttr = aAttrArray[attrIdx];

      // Alter the end offset when text attribute changes its value and stop
      // the search.
      if (!textAttr->Equal(currAcc)) {
        offsetFound = true;
        break;
      }
    }

    if (offsetFound)
      break;

    (*aEndOffset) += nsAccUtils::TextLength(currAcc);
  }
}
Esempio n. 2
0
void
TextAttrsMgr::GetRange(TextAttr* aAttrArray[], PRUint32 aAttrArrayLen,
                       PRInt32* aStartHTOffset, PRInt32* aEndHTOffset)
{
  // Navigate backward from anchor accessible to find start offset.
  for (PRInt32 childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) {
    Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);

    // Stop on embedded accessible since embedded accessibles are combined into
    // own range.
    if (nsAccUtils::IsEmbeddedObject(currAcc))
      break;

    bool offsetFound = false;
    for (PRUint32 attrIdx = 0; attrIdx < aAttrArrayLen; attrIdx++) {
      TextAttr* textAttr = aAttrArray[attrIdx];
      if (!textAttr->Equal(currAcc)) {
        offsetFound = true;
        break;
      }
    }

    if (offsetFound)
      break;

    *(aStartHTOffset) -= nsAccUtils::TextLength(currAcc);
  }

  // Navigate forward from anchor accessible to find end offset.
  PRUint32 childLen = mHyperTextAcc->ChildCount();
  for (PRUint32 childIdx = mOffsetAccIdx + 1; childIdx < childLen; childIdx++) {
    Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
    if (nsAccUtils::IsEmbeddedObject(currAcc))
      break;

    bool offsetFound = false;
    for (PRUint32 attrIdx = 0; attrIdx < aAttrArrayLen; attrIdx++) {
      TextAttr* textAttr = aAttrArray[attrIdx];

      // Alter the end offset when text attribute changes its value and stop
      // the search.
      if (!textAttr->Equal(currAcc)) {
        offsetFound = true;
        break;
      }
    }

    if (offsetFound)
      break;

    (*aEndHTOffset) += nsAccUtils::TextLength(currAcc);
  }
}
Esempio n. 3
0
	bool Menubar::addMenu( const char * pTitle, const Menu_p& pMenu, uint16_t navKey )
	{
		// Sanity check
	
		if( !pTitle || !pMenu )
			return false;
	
		// Convert/copy title
	
		MenuBarItem * pItem = new MenuBarItem();
	
		uint32_t strlen = TextTool::countChars( pTitle );
		pItem->m_pText = new Char[strlen+1];
	
		TextTool::readString(pTitle, pItem->m_pText, strlen+1);
	
		// Calculate linewidth
	
		TextAttr	attr;
		TextTool::addPropAttributes( attr, Base::getDefaultTextprop(), StateEnum::Normal);
		TextTool::addPropAttributes( attr, m_pTextProp, StateEnum::Normal);
		uint32_t lineWidthNormal = TextTool::lineWidth( attr, StateEnum::Normal, pItem->m_pText );
	
		attr.clear();
		TextTool::addPropAttributes( attr, Base::getDefaultTextprop(), StateEnum::Hovered);
		TextTool::addPropAttributes( attr, m_pTextProp, StateEnum::Hovered);
		uint32_t lineWidthMarked = TextTool::lineWidth( attr, StateEnum::Hovered, pItem->m_pText );
	
		if( lineWidthNormal > lineWidthMarked )
			pItem->m_width = lineWidthNormal;
		else
			pItem->m_width = lineWidthMarked;
	
		// Set simple members
	
		pItem->m_navKey		= navKey;
		pItem->m_pMenu		= pMenu;
		pItem->m_pMenuBar	= this;
	
		// Register callbacks
	/*
		pItem->m_pMenu->AddCallback( WgSignal::PointerOutsideModalPos(), cbMoveOutsideModal, this );
		pItem->m_pMenu->AddCallback( WgSignal::MenuClosed(), cbMenuClosed, pItem );
		pItem->m_pMenu->AddCallback( WgSignal::MenuOpened(), cbMenuOpened, pItem );
	*/
		// Finish up
	
		m_items.pushBack(pItem);
		_requestRender();
		return true;
	}