Exemple #1
0
LRESULT CWENavigatorDlg::OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	HWND hwnd = (HWND) wParam;       // handle to window with cursor 
	UINT nHittest = LOWORD(lParam);  // hit-test code 
	UINT wMouseMsg = HIWORD(lParam); // mouse-message identifier 
 
	if (nHittest == HTCLIENT)
	{
		CRect client;
		GetClientRect(&client);

		POINT point;
		GetCursorPos(&point);
		ScreenToClient(&point);

		if (m_layoutView)
		{
			CRect rect;
			rect.left = 3 + (client.Width()-6-m_size.cx)/2;
			rect.top = 3 + (client.Height()-6-16-m_size.cy)/2;
			rect.right = rect.left + m_size.cx;
			rect.bottom = rect.top + m_size.cy;

			if (rect.PtInRect(point))
			{
				int left = 100*m_magnify + 3 + (client.Width()-6-m_size.cx)/2;
				int top = 100*m_magnify + 3 + (client.Height()-6-m_size.cy)/2;

				POINT cpt;
				cpt.x = point.x-left;
				cpt.y = point.y-top;

				CRect viewBox = GetViewBox();

				CRect viewRect = viewBox;

				viewRect.left *= m_magnify;
				viewRect.top *= m_magnify;
				viewRect.right *= m_magnify;
				viewRect.bottom *= m_magnify;

				if (PtInRect(&viewRect, cpt))
				{
					SetCursor(LoadCursor(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDC_HAND0)));
					return TRUE;
				}
				else
				{
					SetCursor(LoadCursor(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDC_HAND1)));
					return TRUE;
				}
			}
		}
	}

	return DefWindowProc(uMsg, wParam, lParam);
}
Exemple #2
0
nsresult
nsSVGPatternFrame::ConstructCTM(nsIDOMSVGMatrix **aCTM,
                                nsIDOMSVGRect *callerBBox,
                                nsIDOMSVGMatrix *callerCTM)
{
  nsCOMPtr<nsIDOMSVGMatrix> tCTM, tempTM;

  // Begin by handling the objectBoundingBox conversion since
  // this must be handled in the CTM
  PRUint16 type = GetPatternContentUnits();

  if (type == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
    // Use the bounding box
    float width, height;
    callerBBox->GetWidth(&width);
    callerBBox->GetHeight(&height);
    NS_NewSVGMatrix(getter_AddRefs(tCTM), width, 0.0f, 0.0f, 
                    height, 0.0f, 0.0f);
  } else {
    float scale = nsSVGUtils::MaxExpansion(callerCTM);
    NS_NewSVGMatrix(getter_AddRefs(tCTM), scale, 0, 0, scale, 0, 0);
  }

  // Do we have a viewbox?
  nsCOMPtr<nsIDOMSVGRect> viewRect;
  GetViewBox(getter_AddRefs(viewRect));

  // See if we really have something
  float viewBoxX, viewBoxY, viewBoxHeight, viewBoxWidth;
  viewRect->GetX(&viewBoxX);
  viewRect->GetY(&viewBoxY);
  viewRect->GetHeight(&viewBoxHeight);
  viewRect->GetWidth(&viewBoxWidth);
  if (viewBoxHeight > 0.0f && viewBoxWidth > 0.0f) {

    float viewportWidth = GetLengthValue(GetWidth());
    float viewportHeight = GetLengthValue(GetHeight());
    float refX = GetLengthValue(GetX());
    float refY = GetLengthValue(GetY());

    nsCOMPtr<nsIDOMSVGAnimatedPreserveAspectRatio> par;
    GetPreserveAspectRatio(getter_AddRefs(par));

    tempTM = nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
                                             viewBoxX + refX, viewBoxY + refY,
                                             viewBoxWidth, viewBoxHeight,
                                             par,
                                             PR_TRUE);

  } else {
    // No viewBox, construct from the (modified) parent matrix
    NS_NewSVGMatrix(getter_AddRefs(tempTM));
  }
  tCTM->Multiply(tempTM, aCTM);
  return NS_OK;
}
Exemple #3
0
void
nsSVGElement::DidChangeViewBox(PRBool aDoSetAttr)
{
  if (!aDoSetAttr)
    return;

  nsSVGViewBox *viewBox = GetViewBox();

  NS_ASSERTION(viewBox, "DidChangeViewBox on element with no viewBox attrib");

  nsAutoString newStr;
  viewBox->GetBaseValueString(newStr);

  SetAttr(kNameSpaceID_None, nsGkAtoms::viewBox, newStr, PR_TRUE);
}
Exemple #4
0
LRESULT CWENavigatorDlg::OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	ATLASSERT(0);
#if 0
	POINT point;
	point.x = (short)LOWORD(lParam);
	point.y = (short)HIWORD(lParam);

	CRect client;
	GetClientRect(&client);

	if (!m_dragging)
	{
		if (m_layoutView)
		{
			CEXMLLayoutView* layoutView = static_cast<CEXMLLayoutView*>(m_layoutView.p);
			CComQIPtr<ILHTMLActiveView> htmlview = layoutView->m_pIOleDocView;
			CComPtr<ILHTMLWindow> window;
			htmlview->GetHTMLWindow(&window);

		//	if (svgdoc)
			{
				int left = 100*m_magnify + 3 + (client.Width()-6-m_size.cx)/2;
				int top = 100*m_magnify + 3 + (client.Height()-6-16-m_size.cy)/2;
			//	int left = 200*m_magnify + 3 + (client.Width()-6-m_size.cx)/2;
			//	int top = 50*m_magnify + 3 + (client.Height()-6-m_size.cy)/2;

				POINT cpt;
				cpt.x = point.x-left;
				cpt.y = point.y-top;

				CRect viewBox = GetViewBox();

				CRect viewRect = viewBox;

				viewRect.left *= m_magnify;
				viewRect.top *= m_magnify;
				viewRect.right *= m_magnify;
				viewRect.bottom *= m_magnify;

				if (PtInRect(&viewRect, cpt))
				{
					m_offset.x = (cpt.x/m_magnify) - viewBox.left;
					m_offset.y = (cpt.y/m_magnify) - viewBox.top;
				}
				else
				{
					m_offset.x = viewBox.Width()/2;
					m_offset.y = viewBox.Height()/2;

					double currentScale;
					window->get_magnify(&currentScale);

					int cx = ((cpt.x/m_magnify) - m_offset.x) * currentScale;
					int cy = ((cpt.y/m_magnify) - m_offset.y) * currentScale;

					window->setCurrentTranslate(-cx, -cy);
				}

				SetCursor(LoadCursor(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDC_HAND2)));

				m_dragging = TRUE;
				SetCapture();
			}
		}
	}
#endif

	return 0;
}
Exemple #5
0
LRESULT CWENavigatorDlg::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	ATLASSERT(0);
#if 0
	CPaintDC dc(m_hWnd);
//	HDC hDC = dc.m_hDC;

	CRect client;
	GetClientRect(&client);

	if (m_layoutView)
	{
		/*
		CComQIPtr<IWebXMLDocument> esvgDocument;
		m_layoutView->get_ESvgDocument(&esvgDocument);
		*/

		CEXMLLayoutView* layoutView = static_cast<CEXMLLayoutView*>(m_layoutView.p);
		CComQIPtr<ILHTMLActiveView> htmlview = layoutView->m_pIOleDocView;
		if (htmlview)
		{
			CComPtr<ILHTMLWindow> window;
			htmlview->GetHTMLWindow(&window);

			CEXMLDocument* pDocument = static_cast<CEXMLDocument*>(layoutView->m_viewGroup->m_pDocument);

			CComPtr<ILDOMDocument> doc;
			pDocument->get_DOMDocument(&doc);

			LSVG::SVGDocument* svgdoc = doc;

			if (svgdoc)
			{
				CComQIPtr<ILSVGSVGElement> svg;
				svgdoc->get_documentElement((ILDOMElement**)&svg);
				if (svg)
				{
					int state = dc.SaveDC();

					double docwidth;
					double docheight;
					window->get_contentWidth(&docwidth);//= pDocument->GetWidth();
					window->get_contentHeight(&docheight);//= pDocument->GetHeight();

					/*
					int fullwidth = docwidth+400;
					int fullheight = docheight+100;
					*/

					CRect rect;
					rect.left = 3 + (client.Width()-6-m_size.cx)/2;
					rect.top = 3 + (client.Height()-6-16-m_size.cy)/2;
					rect.right = rect.left + m_size.cx;
					rect.bottom = rect.top + m_size.cy;

					CRect brect = rect;

					//FillSolidRect(hDC, &rect, RGB(255, 255, 255));

					brect.InflateRect(1, 1);
					dc.Draw3dRect(&brect, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DLIGHT));

					brect.InflateRect(1, 1);
					dc.Draw3dRect(&brect, GetSysColor(COLOR_3DDKSHADOW), GetSysColor(COLOR_3DHILIGHT));

					if (dc.IntersectClipRect(rect.left, rect.top, rect.right, rect.bottom) > NULLREGION)
					{
						if (m_offbm)
						{
							BITMAP bm;
							m_offbm.GetBitmap(&bm);

							if (bm.bmWidth != rect.Width() || bm.bmHeight != rect.Height())
							{
								m_offbm.DeleteObject();
							}
						}

						if (m_offbm == NULL)
						{
							m_offbm.CreateCompatibleBitmap(dc, rect.Width(), rect.Height());
							m_bRedraw = true;
						}


						int x = 100 * m_magnify;
						int y = 100 * m_magnify;

						if (m_bRedraw)
						{
							CDC dc2;
							dc2.CreateCompatibleDC(dc);
							HBITMAP hOldBitmap = (HBITMAP)dc2.SelectBitmap(m_offbm);

							dc2.FillSolidRect(0, 0, rect.Width(), rect.Height(), RGB(255, 255, 255));

							CPoint oldOrg = dc2.SetViewportOrg(x, y);

							CRect prect(0, 0, docwidth*m_magnify, docheight*m_magnify);

							HBRUSH hOldBrush = (HBRUSH)SelectObject(dc2.m_hDC, GetStockObject(NULL_BRUSH));
							Rectangle(dc2.m_hDC, prect.left, prect.top, prect.right, prect.bottom);
							SelectObject(dc2.m_hDC, hOldBrush);

							window->DrawToHdc4(dc2.m_hDC, svg, m_magnify);

							dc2.SetViewportOrg(oldOrg.x, oldOrg.y);

							m_bRedraw = false;

							dc2.SelectBitmap(hOldBitmap);
						}

						if (m_offbm)
						{
							CDC dc2;
							dc2.CreateCompatibleDC(dc);
							HBITMAP hOldBitmap = (HBITMAP)dc2.SelectBitmap(m_offbm);

							dc.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), dc2, 0, 0, SRCCOPY);

							dc2.SelectBitmap(hOldBitmap);
						}

						dc.SetViewportOrg(rect.left+x, rect.top+y);

					// Draw visible viewRect
						{
							CRect viewBox = GetViewBox();

							CRect viewRect = viewBox;
							viewRect.left *= m_magnify;
							viewRect.top *= m_magnify;
							viewRect.right *= m_magnify;
							viewRect.bottom *= m_magnify;

							viewRect.InflateRect(1, 1);

							HPEN hPen = CreatePen(PS_SOLID, 2, m_viewBoxColor);
							HPEN hOldPen = (HPEN)SelectObject(dc.m_hDC, hPen);
							HBRUSH hOldBrush = (HBRUSH)SelectObject(dc.m_hDC, GetStockObject(NULL_BRUSH));

							Rectangle(dc.m_hDC, viewRect.left, viewRect.top, viewRect.right, viewRect.bottom);

							SelectObject(dc.m_hDC, hOldBrush);
							SelectObject(dc.m_hDC, hOldPen);
							DeleteObject(hPen);
						}
					}

					dc.RestoreDC(state);
				}
			}
		}
	}

	m_bUpdate = false;
#endif

	return 0;
}
Exemple #6
0
nsresult
nsSVGElement::UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
                        PRBool aNotify)
{
  PRBool foundMatch = PR_FALSE;

  if (aNamespaceID == kNameSpaceID_None) {
    // If this is an svg presentation attribute, remove rule to force an update
    if (IsAttributeMapped(aName))
      mContentStyleRule = nsnull;

    if (IsEventName(aName)) {
      nsIEventListenerManager* manager = GetListenerManager(PR_FALSE);
      if (manager) {
        nsIAtom* eventName = GetEventNameForAttr(aName);
        manager->RemoveScriptEventListener(eventName);
      }
      foundMatch = PR_TRUE;
    }
    
    if (!foundMatch) {
      // Check if this is a length attribute going away
      LengthAttributesInfo lenInfo = GetLengthInfo();

      for (PRUint32 i = 0; i < lenInfo.mLengthCount; i++) {
        if (aName == *lenInfo.mLengthInfo[i].mName) {
          lenInfo.Reset(i);
          DidChangeLength(i, PR_FALSE);
          foundMatch = PR_TRUE;
          break;
        }
      }
    }

    if (!foundMatch) {
      // Check if this is a number attribute going away
      NumberAttributesInfo numInfo = GetNumberInfo();

      for (PRUint32 i = 0; i < numInfo.mNumberCount; i++) {
        if (aName == *numInfo.mNumberInfo[i].mName) {
          if (i + 1 < numInfo.mNumberCount &&
              aName == *numInfo.mNumberInfo[i + 1].mName) {
            // found a number-optional-number
            numInfo.Reset(i + 1);
            DidChangeNumber(i + 1, PR_FALSE);
          }
          numInfo.Reset(i);
          DidChangeNumber(i, PR_FALSE);
          foundMatch = PR_TRUE;
          break;
        }
      }
    }

    if (!foundMatch) {
      // Check if this is an integer attribute going away
      IntegerAttributesInfo intInfo = GetIntegerInfo();

      for (PRUint32 i = 0; i < intInfo.mIntegerCount; i++) {
        if (aName == *intInfo.mIntegerInfo[i].mName) {
          if (i + 1 < intInfo.mIntegerCount &&
              aName == *intInfo.mIntegerInfo[i + 1].mName) {
            // found a number-optional-number
            intInfo.Reset(i + 1);
            DidChangeNumber(i + 1, PR_FALSE);
          }
          intInfo.Reset(i);
          DidChangeInteger(i, PR_FALSE);
          foundMatch = PR_TRUE;
          break;
        }
      }
    }

    if (!foundMatch) {
      // Check if this is an angle attribute going away
      AngleAttributesInfo angleInfo = GetAngleInfo();

      for (PRUint32 i = 0; i < angleInfo.mAngleCount; i++) {
        if (aName == *angleInfo.mAngleInfo[i].mName) {
          angleInfo.Reset(i);
          DidChangeAngle(i, PR_FALSE);
          foundMatch = PR_TRUE;
          break;
        }
      }
    }

    if (!foundMatch) {
      // Check if this is a boolean attribute going away
      BooleanAttributesInfo boolInfo = GetBooleanInfo();

      for (PRUint32 i = 0; i < boolInfo.mBooleanCount; i++) {
        if (aName == *boolInfo.mBooleanInfo[i].mName) {
          boolInfo.Reset(i);
          DidChangeBoolean(i, PR_FALSE);
          foundMatch = PR_TRUE;
        }
      }
    }

    if (!foundMatch) {
      // Check if this is an enum attribute going away
      EnumAttributesInfo enumInfo = GetEnumInfo();

      for (PRUint32 i = 0; i < enumInfo.mEnumCount; i++) {
        if (aName == *enumInfo.mEnumInfo[i].mName) {
          enumInfo.Reset(i);
          DidChangeEnum(i, PR_FALSE);
          foundMatch = PR_TRUE;
          break;
        }
      }
    }

    if (!foundMatch) {
      // Check if this is a nsViewBox attribute going away
      if (aName == nsGkAtoms::viewBox) {
        nsSVGViewBox* viewBox = GetViewBox();
        if (viewBox) {
          viewBox->Init();
          DidChangeViewBox(PR_FALSE);
          foundMatch = PR_TRUE;
        }
      // Check if this is a preserveAspectRatio attribute going away
      } else if (aName == nsGkAtoms::preserveAspectRatio) {
        nsSVGPreserveAspectRatio *preserveAspectRatio =
          GetPreserveAspectRatio();

        if (preserveAspectRatio) {
          preserveAspectRatio->Init();
          DidChangePreserveAspectRatio(PR_FALSE);
          foundMatch = PR_TRUE;
        }
      }
    }
  }

  if (!foundMatch) {
    // Check if this is a string attribute going away
    StringAttributesInfo stringInfo = GetStringInfo();

    for (PRUint32 i = 0; i < stringInfo.mStringCount; i++) {
      if (aNamespaceID == stringInfo.mStringInfo[i].mNamespaceID &&
          aName == *stringInfo.mStringInfo[i].mName) {
        stringInfo.Reset(i);
        DidChangeString(i);
        foundMatch = PR_TRUE;
        break;
      }
    }
  }

  if (!foundMatch) {
    // Now check for one of the old style basetypes going away
    nsCOMPtr<nsISVGValue> svg_value = GetMappedAttribute(aNamespaceID, aName);

    if (svg_value) {
      mSuppressNotification = PR_TRUE;
      ResetOldStyleBaseType(svg_value);
      mSuppressNotification = PR_FALSE;
    }
  }

  return nsSVGElementBase::UnsetAttr(aNamespaceID, aName, aNotify);
}
Exemple #7
0
PRBool
nsSVGElement::ParseAttribute(PRInt32 aNamespaceID,
                             nsIAtom* aAttribute,
                             const nsAString& aValue,
                             nsAttrValue& aResult)
{
  // Parse value
  nsCOMPtr<nsISVGValue> svg_value;
  const nsAttrValue* val = mAttrsAndChildren.GetAttr(aAttribute, aNamespaceID);
  if (val) {
    // Found the attr in the list.
    if (val->Type() == nsAttrValue::eSVGValue) {
      svg_value = val->GetSVGValue();
    }
  }
  else {
    // Could be a mapped attribute.
    svg_value = GetMappedAttribute(aNamespaceID, aAttribute);
  }
  
  if (svg_value) {
    // We want to prevent DidModifySVGObservable from running if we
    // come in this route, otherwise AttributeChanged() gets called
    // twice (once through DidMOdifySVGObservable, once through SetAttr).
    mSuppressNotification = PR_TRUE;

    if (NS_FAILED(svg_value->SetValueString(aValue))) {
      // The value was rejected. This happens e.g. in a XUL template
      // when trying to set a value like "?x" on a value object that
      // expects a length.
      // To accommodate this "erroneous" value, we'll insert a proxy
      // object between ourselves and the actual value object:
      ReportAttributeParseFailure(GetOwnerDoc(), aAttribute, aValue);
      nsCOMPtr<nsISVGValue> proxy;
      nsresult rv =
        NS_CreateSVGStringProxyValue(svg_value, getter_AddRefs(proxy));
      // Failure means we'll store this attr as a string, not an SVGValue, but
      // that's the best we can do short of throwing outright.
      NS_ENSURE_SUCCESS(rv, PR_FALSE);

      svg_value->RemoveObserver(this);
      ResetOldStyleBaseType(svg_value);
      proxy->SetValueString(aValue);
      proxy->AddObserver(this);
      aResult.SetTo(proxy);
    }
    else {
      aResult.SetTo(svg_value);
    }
    mSuppressNotification = PR_FALSE;
    return PR_TRUE;
  }

  nsresult rv = NS_OK;
  PRBool foundMatch = PR_FALSE;
  if (aNamespaceID == kNameSpaceID_None) {

    // Check for nsSVGLength2 attribute
    LengthAttributesInfo lengthInfo = GetLengthInfo();

    PRUint32 i;
    for (i = 0; i < lengthInfo.mLengthCount; i++) {
      if (aAttribute == *lengthInfo.mLengthInfo[i].mName) {
        rv = lengthInfo.mLengths[i].SetBaseValueString(aValue, this, PR_FALSE);
        if (NS_FAILED(rv)) {
          lengthInfo.Reset(i);
        }
        foundMatch = PR_TRUE;
        break;
      }
    }

    if (!foundMatch) {
      // Check for nsSVGNumber2 attribute
      NumberAttributesInfo numberInfo = GetNumberInfo();
      for (i = 0; i < numberInfo.mNumberCount; i++) {
        if (aAttribute == *numberInfo.mNumberInfo[i].mName) {
          if (i + 1 < numberInfo.mNumberCount &&
              aAttribute == *numberInfo.mNumberInfo[i + 1].mName) {
            rv = ParseNumberOptionalNumber(aValue, i, i + 1);
            if (NS_FAILED(rv)) {
              numberInfo.Reset(i + 1);
            }
          } else {
            rv = numberInfo.mNumbers[i].SetBaseValueString(aValue, this, PR_FALSE);
          }
          if (NS_FAILED(rv)) {
            numberInfo.Reset(i);
          }
          foundMatch = PR_TRUE;
          break;
        }
      }
    }

    if (!foundMatch) {
      // Check for nsSVGInteger attribute
      IntegerAttributesInfo integerInfo = GetIntegerInfo();
      for (i = 0; i < integerInfo.mIntegerCount; i++) {
        if (aAttribute == *integerInfo.mIntegerInfo[i].mName) {
          if (i + 1 < integerInfo.mIntegerCount &&
              aAttribute == *integerInfo.mIntegerInfo[i + 1].mName) {
            rv = ParseIntegerOptionalInteger(aValue, i, i + 1);
            if (NS_FAILED(rv)) {
              integerInfo.Reset(i + 1);
            }
          } else {
            rv = integerInfo.mIntegers[i].SetBaseValueString(aValue, this, PR_FALSE);
          }
          if (NS_FAILED(rv)) {
            integerInfo.Reset(i);
          }
          foundMatch = PR_TRUE;
          break;
        }
      }
    }

    if (!foundMatch) {
      // Check for nsSVGAngle attribute
      AngleAttributesInfo angleInfo = GetAngleInfo();
      for (i = 0; i < angleInfo.mAngleCount; i++) {
        if (aAttribute == *angleInfo.mAngleInfo[i].mName) {
          rv = angleInfo.mAngles[i].SetBaseValueString(aValue, this, PR_FALSE);
          if (NS_FAILED(rv)) {
            angleInfo.Reset(i);
          }
          foundMatch = PR_TRUE;
          break;
        }
      }
    }

    if (!foundMatch) {
      // Check for nsSVGBoolean attribute
      BooleanAttributesInfo booleanInfo = GetBooleanInfo();
      for (i = 0; i < booleanInfo.mBooleanCount; i++) {
        if (aAttribute == *booleanInfo.mBooleanInfo[i].mName) {
          rv = booleanInfo.mBooleans[i].SetBaseValueString(aValue, this, PR_FALSE);
          if (NS_FAILED(rv)) {
            booleanInfo.Reset(i);
          }
          foundMatch = PR_TRUE;
          break;
        }
      }
    }

    if (!foundMatch) {
      // Check for nsSVGEnum attribute
      EnumAttributesInfo enumInfo = GetEnumInfo();
      for (i = 0; i < enumInfo.mEnumCount; i++) {
        if (aAttribute == *enumInfo.mEnumInfo[i].mName) {
          rv = enumInfo.mEnums[i].SetBaseValueString(aValue, this, PR_FALSE);
          if (NS_FAILED(rv)) {
            enumInfo.Reset(i);
          }
          foundMatch = PR_TRUE;
          break;
        }
      }
    }

    if (!foundMatch) {
      // Check for nsSVGViewBox attribute
      if (aAttribute == nsGkAtoms::viewBox) {
        nsSVGViewBox* viewBox = GetViewBox();
        if (viewBox) {
          rv = viewBox->SetBaseValueString(aValue, this, PR_FALSE);
          if (NS_FAILED(rv)) {
            viewBox->Init();
          }
          foundMatch = PR_TRUE;
        }
      // Check for nsSVGPreserveAspectRatio attribute
      } else if (aAttribute == nsGkAtoms::preserveAspectRatio) {
        nsSVGPreserveAspectRatio *preserveAspectRatio =
          GetPreserveAspectRatio();
        if (preserveAspectRatio) {
          rv = preserveAspectRatio->SetBaseValueString(aValue, this, PR_FALSE);
          if (NS_FAILED(rv)) {
            preserveAspectRatio->Init();
          }
          foundMatch = PR_TRUE;
        }
      }
    }
  }

  if (!foundMatch) {
    // Check for nsSVGString attribute
    StringAttributesInfo stringInfo = GetStringInfo();
    for (PRUint32 i = 0; i < stringInfo.mStringCount; i++) {
      if (aNamespaceID == stringInfo.mStringInfo[i].mNamespaceID &&
          aAttribute == *stringInfo.mStringInfo[i].mName) {
        stringInfo.mStrings[i].SetBaseValue(aValue, this, PR_FALSE);
        foundMatch = PR_TRUE;
        break;
      }
    }
  }

  if (foundMatch) {
    if (NS_FAILED(rv)) {
      ReportAttributeParseFailure(GetOwnerDoc(), aAttribute, aValue);
      return PR_FALSE;
    }
    aResult.SetTo(aValue);
    return PR_TRUE;
  }

  return nsSVGElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue,
                                          aResult);
}
Exemple #8
0
nsresult
nsSVGElement::Init()
{
  // Set up length attributes - can't do this in the constructor
  // because we can't do a virtual call at that point

  LengthAttributesInfo lengthInfo = GetLengthInfo();

  PRUint32 i;
  for (i = 0; i < lengthInfo.mLengthCount; i++) {
    lengthInfo.Reset(i);
  }

  NumberAttributesInfo numberInfo = GetNumberInfo();

  for (i = 0; i < numberInfo.mNumberCount; i++) {
    numberInfo.Reset(i);
  }

  IntegerAttributesInfo integerInfo = GetIntegerInfo();

  for (i = 0; i < integerInfo.mIntegerCount; i++) {
    integerInfo.Reset(i);
  }

  AngleAttributesInfo angleInfo = GetAngleInfo();

  for (i = 0; i < angleInfo.mAngleCount; i++) {
    angleInfo.Reset(i);
  }

  BooleanAttributesInfo booleanInfo = GetBooleanInfo();

  for (i = 0; i < booleanInfo.mBooleanCount; i++) {
    booleanInfo.Reset(i);
  }

  EnumAttributesInfo enumInfo = GetEnumInfo();

  for (i = 0; i < enumInfo.mEnumCount; i++) {
    enumInfo.Reset(i);
  }

  nsSVGViewBox *viewBox = GetViewBox();

  if (viewBox) {
    viewBox->Init();
  }

  nsSVGPreserveAspectRatio *preserveAspectRatio =
    GetPreserveAspectRatio();

  if (preserveAspectRatio) {
    preserveAspectRatio->Init();
  }

  StringAttributesInfo stringInfo = GetStringInfo();

  for (i = 0; i < stringInfo.mStringCount; i++) {
    stringInfo.Reset(i);
  }

  return NS_OK;
}