コード例 #1
0
ファイル: nsImageMap.cpp プロジェクト: blue119/gecko-dev
nsresult
nsImageMap::AddArea(nsIContent* aArea)
{
  static nsIContent::AttrValuesArray strings[] =
    {&nsGkAtoms::rect, &nsGkAtoms::rectangle,
     &nsGkAtoms::circle, &nsGkAtoms::circ,
     &nsGkAtoms::_default,
     &nsGkAtoms::poly, &nsGkAtoms::polygon,
     nullptr};

  Area* area;
  switch (aArea->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::shape,
                                 strings, eIgnoreCase)) {
  case nsIContent::ATTR_VALUE_NO_MATCH:
  case nsIContent::ATTR_MISSING:
  case 0:
  case 1:
    area = new RectArea(aArea);
    break;
  case 2:
  case 3:
    area = new CircleArea(aArea);
    break;
  case 4:
    area = new DefaultArea(aArea);
    break;
  case 5:
  case 6:
    area = new PolyArea(aArea);
    break;
  default:
    area = nullptr;
    NS_NOTREACHED("FindAttrValueIn returned an unexpected value.");
    break;
  }
  if (!area)
    return NS_ERROR_OUT_OF_MEMORY;

  //Add focus listener to track area focus changes
  aArea->AddSystemEventListener(NS_LITERAL_STRING("focus"), this, false,
                                false);
  aArea->AddSystemEventListener(NS_LITERAL_STRING("blur"), this, false,
                                false);

  // This is a nasty hack.  It needs to go away: see bug 135040.  Once this is
  // removed, the code added to RestyleManager::RestyleElement,
  // nsCSSFrameConstructor::ContentRemoved (both hacks there), and
  // RestyleManager::ProcessRestyledFrames to work around this issue can
  // be removed.
  aArea->SetPrimaryFrame(mImageFrame);

  nsAutoString coords;
  aArea->GetAttr(kNameSpaceID_None, nsGkAtoms::coords, coords);
  area->ParseCoords(coords);
  mAreas.AppendElement(area);
  return NS_OK;
}
コード例 #2
0
nsresult
nsImageMap::AddArea(nsIContent* aArea)
{
  nsAutoString coords;
  static nsIContent::AttrValuesArray strings[] =
    {&nsGkAtoms::_empty, &nsGkAtoms::rect, &nsGkAtoms::rectangle,
     &nsGkAtoms::poly, &nsGkAtoms::polygon, &nsGkAtoms::circle,
     &nsGkAtoms::circ, &nsGkAtoms::_default, nsnull};

  aArea->GetAttr(kNameSpaceID_None, nsGkAtoms::coords, coords);

  Area* area;
  switch (aArea->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::shape,
                                 strings, eIgnoreCase)) {
    case nsIContent::ATTR_MISSING:
    case 0:
    case 1:
    case 2:
      area = new RectArea(aArea);
      break;
    case 3:
    case 4:
      area = new PolyArea(aArea);
      break;
    case 5:
    case 6:
      area = new CircleArea(aArea);
      break;
    case 7:
      area = new DefaultArea(aArea);
      break;
    default:
      // Unknown area type; bail
      return NS_OK;
  }
  if (!area)
    return NS_ERROR_OUT_OF_MEMORY;

  //Add focus listener to track area focus changes
  aArea->AddEventListenerByIID(this, NS_GET_IID(nsIDOMFocusListener));

  // This is a nasty hack.  It needs to go away: see bug 135040.  Once this is
  // removed, the code added to nsCSSFrameConstructor::RestyleElement,
  // nsCSSFrameConstructor::ContentRemoved (both hacks there), and
  // nsCSSFrameConstructor::ProcessRestyledFrames to work around this issue can
  // be removed.
  aArea->SetPrimaryFrame(mImageFrame);

  area->ParseCoords(coords);
  mAreas.AppendElement(area);
  return NS_OK;
}