Bug 894737 - [Buri][WIFI-hotspot]Wi-Fi hotspot will be turn off automatic when change the security. r=mrbkap

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- *//* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */// Keep in (case-insensitive) order:#include"nsIAnonymousContentCreator.h"#include"nsSVGEffects.h"#include"nsSVGGFrame.h"#include"mozilla/dom/SVGUseElement.h"#include"nsContentList.h"typedefnsSVGGFramensSVGUseFrameBase;usingnamespacemozilla::dom;classnsSVGUseFrame:publicnsSVGUseFrameBase,publicnsIAnonymousContentCreator{friendnsIFrame*NS_NewSVGUseFrame(nsIPresShell*aPresShell,nsStyleContext*aContext);protected:nsSVGUseFrame(nsStyleContext*aContext):nsSVGUseFrameBase(aContext),mHasValidDimensions(true){}public:NS_DECL_QUERYFRAMENS_DECL_FRAMEARENA_HELPERS// nsIFrame interface:virtualvoidInit(nsIContent*aContent,nsIFrame*aParent,nsIFrame*aPrevInFlow)MOZ_OVERRIDE;NS_IMETHODAttributeChanged(int32_taNameSpaceID,nsIAtom*aAttribute,int32_taModType);virtualvoidDestroyFrom(nsIFrame*aDestructRoot);/** * Get the "type" of the frame * * @see nsGkAtoms::svgUseFrame */virtualnsIAtom*GetType()const;virtualboolIsLeaf()const;#ifdef DEBUGNS_IMETHODGetFrameName(nsAString&aResult)const{returnMakeFrameName(NS_LITERAL_STRING("SVGUse"),aResult);}#endif// nsISVGChildFrame interface:virtualvoidReflowSVG();virtualvoidNotifySVGChanged(uint32_taFlags);// nsIAnonymousContentCreatorvirtualnsresultCreateAnonymousContent(nsTArray<ContentInfo>&aElements);virtualvoidAppendAnonymousContentTo(nsBaseContentList&aElements,uint32_taFilter);private:boolmHasValidDimensions;};//----------------------------------------------------------------------// ImplementationnsIFrame*NS_NewSVGUseFrame(nsIPresShell*aPresShell,nsStyleContext*aContext){returnnew(aPresShell)nsSVGUseFrame(aContext);}NS_IMPL_FRAMEARENA_HELPERS(nsSVGUseFrame)nsIAtom*nsSVGUseFrame::GetType()const{returnnsGkAtoms::svgUseFrame;}//----------------------------------------------------------------------// nsQueryFrame methodsNS_QUERYFRAME_HEAD(nsSVGUseFrame)NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)NS_QUERYFRAME_TAIL_INHERITING(nsSVGUseFrameBase)//----------------------------------------------------------------------// nsIFrame methods:voidnsSVGUseFrame::Init(nsIContent*aContent,nsIFrame*aParent,nsIFrame*aPrevInFlow){NS_ASSERTION(aContent->IsSVG(nsGkAtoms::use),"Content is not an SVG use!");mHasValidDimensions=static_cast<SVGUseElement*>(aContent)->HasValidDimensions();nsSVGUseFrameBase::Init(aContent,aParent,aPrevInFlow);}NS_IMETHODIMPnsSVGUseFrame::AttributeChanged(int32_taNameSpaceID,nsIAtom*aAttribute,int32_taModType){SVGUseElement*useElement=static_cast<SVGUseElement*>(mContent);if(aNameSpaceID==kNameSpaceID_None){if(aAttribute==nsGkAtoms::x||aAttribute==nsGkAtoms::y){// make sure our cached transform matrix gets (lazily) updatedmCanvasTM=nullptr;nsSVGEffects::InvalidateRenderingObservers(this);nsSVGUtils::ScheduleReflowSVG(this);nsSVGUtils::NotifyChildrenOfSVGChange(this,TRANSFORM_CHANGED);}elseif(aAttribute==nsGkAtoms::width||aAttribute==nsGkAtoms::height){boolinvalidate=false;if(mHasValidDimensions!=useElement->HasValidDimensions()){mHasValidDimensions=!mHasValidDimensions;invalidate=true;}if(useElement->OurWidthAndHeightAreUsed()){invalidate=true;useElement->SyncWidthOrHeight(aAttribute);}if(invalidate){nsSVGEffects::InvalidateRenderingObservers(this);nsSVGUtils::ScheduleReflowSVG(this);}}}elseif(aNameSpaceID==kNameSpaceID_XLink&&aAttribute==nsGkAtoms::href){// we're changing our nature, clear out the clone informationnsSVGEffects::InvalidateRenderingObservers(this);nsSVGUtils::ScheduleReflowSVG(this);useElement->mOriginal=nullptr;useElement->UnlinkSource();useElement->TriggerReclone();}returnnsSVGUseFrameBase::AttributeChanged(aNameSpaceID,aAttribute,aModType);}voidnsSVGUseFrame::DestroyFrom(nsIFrame*aDestructRoot){nsRefPtr<SVGUseElement>use=static_cast<SVGUseElement*>(mContent);nsSVGUseFrameBase::DestroyFrom(aDestructRoot);use->DestroyAnonymousContent();}boolnsSVGUseFrame::IsLeaf()const{returntrue;}//----------------------------------------------------------------------// nsISVGChildFrame methodsvoidnsSVGUseFrame::ReflowSVG(){// We only handle x/y offset here, since any width/height that is in force is// handled by the nsSVGOuterSVGFrame for the anonymous <svg> that will be// created for that purpose.floatx,y;static_cast<SVGUseElement*>(mContent)->GetAnimatedLengthValues(&x,&y,nullptr);mRect.MoveTo(nsLayoutUtils::RoundGfxRectToAppRect(gfxRect(x,y,0.0,0.0),PresContext()->AppUnitsPerCSSPixel()).TopLeft());nsSVGUseFrameBase::ReflowSVG();}voidnsSVGUseFrame::NotifySVGChanged(uint32_taFlags){if(aFlags&COORD_CONTEXT_CHANGED&&!(aFlags&TRANSFORM_CHANGED)){// Coordinate context changes affect mCanvasTM if we have a// percentage 'x' or 'y'SVGUseElement*use=static_cast<SVGUseElement*>(mContent);if(use->mLengthAttributes[SVGUseElement::ATTR_X].IsPercentage()||use->mLengthAttributes[SVGUseElement::ATTR_Y].IsPercentage()){aFlags|=TRANSFORM_CHANGED;// Ancestor changes can't affect how we render from the perspective of// any rendering observers that we may have, so we don't need to// invalidate them. We also don't need to invalidate ourself, since our// changed ancestor will have invalidated its entire area, which includes// our area.// For perf reasons we call this before calling NotifySVGChanged() below.nsSVGUtils::ScheduleReflowSVG(this);}}// We don't remove the TRANSFORM_CHANGED flag here if we have a viewBox or// non-percentage width/height, since if they're set then they are cloned to// an anonymous child <svg>, and its nsSVGInnerSVGFrame will do that.nsSVGUseFrameBase::NotifySVGChanged(aFlags);}//----------------------------------------------------------------------// nsIAnonymousContentCreator methods:nsresultnsSVGUseFrame::CreateAnonymousContent(nsTArray<ContentInfo>&aElements){SVGUseElement*use=static_cast<SVGUseElement*>(mContent);nsIContent*clone=use->CreateAnonymousContent();nsSVGEffects::InvalidateRenderingObservers(this);if(!clone)returnNS_ERROR_FAILURE;if(!aElements.AppendElement(clone))returnNS_ERROR_OUT_OF_MEMORY;returnNS_OK;}voidnsSVGUseFrame::AppendAnonymousContentTo(nsBaseContentList&aElements,uint32_taFilter){SVGUseElement*use=static_cast<SVGUseElement*>(mContent);nsIContent*clone=use->GetAnonymousContent();aElements.MaybeAppendElement(clone);}