зеркало из https://github.com/mozilla/gecko-dev.git
Get default tooltip text more reliably b=147670 r=timeless sr=jst
This commit is contained in:
Родитель
34a88eba03
Коммит
0eb7427fc2
|
@ -6439,8 +6439,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsFrameConstructorState& aState,
|
|||
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
|
||||
NS_ASSERTION(rootBox, "unexpected null pointer");
|
||||
if (rootBox) {
|
||||
nsIFrame* popupSetFrame;
|
||||
rootBox->GetPopupSetFrame(&popupSetFrame);
|
||||
nsIFrame* popupSetFrame = rootBox->GetPopupSetFrame();
|
||||
NS_ASSERTION(popupSetFrame, "unexpected null pointer");
|
||||
if (popupSetFrame) {
|
||||
nsCOMPtr<nsIPopupSetFrame> popupSet(do_QueryInterface(popupSetFrame));
|
||||
|
@ -9807,8 +9806,7 @@ DeletingFrameSubtree(nsPresContext* aPresContext,
|
|||
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
|
||||
NS_ASSERTION(rootBox, "unexpected null pointer");
|
||||
if (rootBox) {
|
||||
nsIFrame* popupSetFrame;
|
||||
rootBox->GetPopupSetFrame(&popupSetFrame);
|
||||
nsIFrame* popupSetFrame = rootBox->GetPopupSetFrame();
|
||||
NS_ASSERTION(popupSetFrame, "unexpected null pointer");
|
||||
if (popupSetFrame) {
|
||||
nsCOMPtr<nsIPopupSetFrame> popupSet(do_QueryInterface(popupSetFrame));
|
||||
|
@ -10022,8 +10020,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
|
|||
#ifdef MOZ_XUL
|
||||
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
|
||||
if (rootBox) {
|
||||
nsIFrame* popupSetFrame;
|
||||
rootBox->GetPopupSetFrame(&popupSetFrame);
|
||||
nsIFrame* popupSetFrame = rootBox->GetPopupSetFrame();
|
||||
if (popupSetFrame) {
|
||||
nsCOMPtr<nsIPopupSetFrame> popupSet(do_QueryInterface(popupSetFrame));
|
||||
if (popupSet)
|
||||
|
|
|
@ -53,14 +53,14 @@ class nsIRootBox : public nsISupports {
|
|||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IROOTBOX_IID)
|
||||
|
||||
NS_IMETHOD GetPopupSetFrame(nsIFrame** aResult)=0;
|
||||
NS_IMETHOD SetPopupSetFrame(nsIFrame* aPopupSet)=0;
|
||||
virtual nsIFrame* GetPopupSetFrame() = 0;
|
||||
virtual void SetPopupSetFrame(nsIFrame* aPopupSet)=0;
|
||||
|
||||
NS_IMETHOD GetDefaultTooltip(nsIContent** aResult)=0;
|
||||
NS_IMETHOD SetDefaultTooltip(nsIContent* aTooltip)=0;
|
||||
virtual nsIContent* GetDefaultTooltip() = 0;
|
||||
virtual void SetDefaultTooltip(nsIContent* aTooltip) = 0;
|
||||
|
||||
NS_IMETHOD AddTooltipSupport(nsIContent* aNode)=0;
|
||||
NS_IMETHOD RemoveTooltipSupport(nsIContent* aNode)=0;
|
||||
virtual nsresult AddTooltipSupport(nsIContent* aNode) = 0;
|
||||
virtual nsresult RemoveTooltipSupport(nsIContent* aNode) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -98,8 +98,7 @@ GetPopupSetFrame(nsPresContext* aPresContext)
|
|||
if (!rootBox)
|
||||
return nsnull;
|
||||
|
||||
nsIFrame* popupSetFrame;
|
||||
rootBox->GetPopupSetFrame(&popupSetFrame);
|
||||
nsIFrame* popupSetFrame = rootBox->GetPopupSetFrame();
|
||||
if (!popupSetFrame)
|
||||
return nsnull;
|
||||
|
||||
|
|
|
@ -116,8 +116,7 @@ nsPopupBoxObject::HidePopup()
|
|||
if (!rootBox)
|
||||
return NS_OK;
|
||||
|
||||
nsIFrame* popupSetFrame;
|
||||
rootBox->GetPopupSetFrame(&popupSetFrame);
|
||||
nsIFrame* popupSetFrame = rootBox->GetPopupSetFrame();
|
||||
if (!popupSetFrame)
|
||||
return NS_OK;
|
||||
|
||||
|
@ -150,8 +149,7 @@ nsPopupBoxObject::ShowPopup(nsIDOMElement* aSrcContent,
|
|||
if (!rootBox)
|
||||
return NS_OK;
|
||||
|
||||
nsIFrame* popupSetFrame;
|
||||
rootBox->GetPopupSetFrame(&popupSetFrame);
|
||||
nsIFrame* popupSetFrame = rootBox->GetPopupSetFrame();
|
||||
if (!popupSetFrame)
|
||||
return NS_OK;
|
||||
|
||||
|
|
|
@ -74,12 +74,12 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_IMETHOD GetPopupSetFrame(nsIFrame** aResult);
|
||||
NS_IMETHOD SetPopupSetFrame(nsIFrame* aPopupSet);
|
||||
NS_IMETHOD GetDefaultTooltip(nsIContent** aResult);
|
||||
NS_IMETHOD SetDefaultTooltip(nsIContent* aTooltip);
|
||||
NS_IMETHOD AddTooltipSupport(nsIContent* aNode);
|
||||
NS_IMETHOD RemoveTooltipSupport(nsIContent* aNode);
|
||||
virtual nsIFrame* GetPopupSetFrame();
|
||||
virtual void SetPopupSetFrame(nsIFrame* aPopupSet);
|
||||
virtual nsIContent* GetDefaultTooltip();
|
||||
virtual void SetDefaultTooltip(nsIContent* aTooltip);
|
||||
virtual nsresult AddTooltipSupport(nsIContent* aNode);
|
||||
virtual nsresult RemoveTooltipSupport(nsIContent* aNode);
|
||||
|
||||
NS_IMETHOD AppendFrames(nsIAtom* aListName,
|
||||
nsIFrame* aFrameList);
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
virtual nsIAtom* GetType() const;
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
||||
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
||||
#endif
|
||||
|
||||
nsIFrame* mPopupSetFrame;
|
||||
|
@ -258,14 +258,13 @@ nsRootBoxFrame::GetType() const
|
|||
return nsLayoutAtoms::rootFrame;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRootBoxFrame::GetPopupSetFrame(nsIFrame** aResult)
|
||||
nsIFrame*
|
||||
nsRootBoxFrame::GetPopupSetFrame()
|
||||
{
|
||||
*aResult = mPopupSetFrame;
|
||||
return NS_OK;
|
||||
return mPopupSetFrame;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsRootBoxFrame::SetPopupSetFrame(nsIFrame* aPopupSet)
|
||||
{
|
||||
// Under normal conditions this should only be called once. However,
|
||||
|
@ -281,24 +280,21 @@ nsRootBoxFrame::SetPopupSetFrame(nsIFrame* aPopupSet)
|
|||
} else {
|
||||
NS_NOTREACHED("Popup set is already defined! Only 1 allowed.");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRootBoxFrame::GetDefaultTooltip(nsIContent** aTooltip)
|
||||
nsIContent*
|
||||
nsRootBoxFrame::GetDefaultTooltip()
|
||||
{
|
||||
*aTooltip = mDefaultTooltip;
|
||||
return NS_OK;
|
||||
return mDefaultTooltip;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsRootBoxFrame::SetDefaultTooltip(nsIContent* aTooltip)
|
||||
{
|
||||
mDefaultTooltip = aTooltip;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsRootBoxFrame::AddTooltipSupport(nsIContent* aNode)
|
||||
{
|
||||
// listener will be refcounted by dom event targets that
|
||||
|
@ -312,7 +308,7 @@ nsRootBoxFrame::AddTooltipSupport(nsIContent* aNode)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsRootBoxFrame::RemoveTooltipSupport(nsIContent* aNode)
|
||||
{
|
||||
// XXjh yuck, I'll have to implement a way to get at
|
||||
|
@ -340,7 +336,7 @@ NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame)
|
|||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHODIMP
|
||||
nsRootBoxFrame::GetFrameName(nsString& aResult) const
|
||||
nsRootBoxFrame::GetFrameName(nsAString& aResult) const
|
||||
{
|
||||
return MakeFrameName(NS_LITERAL_STRING("RootBox"), aResult);
|
||||
}
|
||||
|
|
|
@ -563,10 +563,6 @@ nsXULTooltipListener::GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip)
|
|||
if (!aTarget)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> targetEl(do_QueryInterface(aTarget));
|
||||
if (!targetEl)
|
||||
return NS_ERROR_FAILURE; // could be a text node or something
|
||||
|
||||
// before we go on, make sure that target node still has a window
|
||||
nsCOMPtr<nsIDocument> document = aTarget->GetDocument();
|
||||
if (!document) {
|
||||
|
@ -582,54 +578,50 @@ nsXULTooltipListener::GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip)
|
|||
if (!domWindow)
|
||||
return NS_ERROR_FAILURE;
|
||||
else {
|
||||
PRBool needTooltip;
|
||||
targetEl->HasAttribute(NS_LITERAL_STRING("tooltiptext"), &needTooltip);
|
||||
if (needTooltip) {
|
||||
nsAutoString tooltipText;
|
||||
aTarget->GetAttr(kNameSpaceID_None, nsXULAtoms::tooltiptext, tooltipText);
|
||||
if (!tooltipText.IsEmpty()) {
|
||||
// specifying tooltiptext means we will always use the default tooltip
|
||||
mRootBox->GetDefaultTooltip(aTooltip);
|
||||
NS_IF_ADDREF(*aTooltip);
|
||||
return NS_OK;
|
||||
} else {
|
||||
nsAutoString tooltipId;
|
||||
targetEl->GetAttribute(NS_LITERAL_STRING("tooltip"), tooltipId);
|
||||
*aTooltip = mRootBox->GetDefaultTooltip();
|
||||
if (*aTooltip) {
|
||||
NS_ADDREF(*aTooltip);
|
||||
(*aTooltip)->SetAttr(kNameSpaceID_None, nsXULAtoms::label, tooltipText, PR_TRUE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
nsAutoString tooltipId;
|
||||
aTarget->GetAttr(kNameSpaceID_None, nsXULAtoms::tooltip, tooltipId);
|
||||
|
||||
// if tooltip == _child, look for first <tooltip> child
|
||||
if (tooltipId.EqualsLiteral("_child")) {
|
||||
GetImmediateChild(aTarget, nsXULAtoms::tooltip, aTooltip);
|
||||
return NS_OK;
|
||||
} else {
|
||||
if (!tooltipId.IsEmpty()) {
|
||||
// tooltip must be an id, use getElementById to find it
|
||||
nsCOMPtr<nsIDOMDocument> domDocument =
|
||||
do_QueryInterface(document);
|
||||
if (!domDocument) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// if tooltip == _child, look for first <tooltip> child
|
||||
if (tooltipId.EqualsLiteral("_child")) {
|
||||
GetImmediateChild(aTarget, nsXULAtoms::tooltip, aTooltip);
|
||||
return NS_OK;
|
||||
}
|
||||
if (!tooltipId.IsEmpty()) {
|
||||
// tooltip must be an id, use getElementById to find it
|
||||
nsCOMPtr<nsIDOMDocument> domDocument =
|
||||
do_QueryInterface(document);
|
||||
if (!domDocument) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMElement> tooltipEl;
|
||||
domDocument->GetElementById(tooltipId,
|
||||
getter_AddRefs(tooltipEl));
|
||||
nsCOMPtr<nsIDOMElement> tooltipEl;
|
||||
domDocument->GetElementById(tooltipId,
|
||||
getter_AddRefs(tooltipEl));
|
||||
|
||||
if (tooltipEl) {
|
||||
if (tooltipEl) {
|
||||
#ifdef MOZ_XUL
|
||||
mNeedTitletip = PR_FALSE;
|
||||
mNeedTitletip = PR_FALSE;
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIContent> tooltipContent(do_QueryInterface(tooltipEl));
|
||||
*aTooltip = tooltipContent;
|
||||
NS_IF_ADDREF(*aTooltip);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
CallQueryInterface(tooltipEl, aTooltip);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
// titletips should just use the default tooltip
|
||||
if (mIsSourceTree && mNeedTitletip) {
|
||||
mRootBox->GetDefaultTooltip(aTooltip);
|
||||
NS_IF_ADDREF(*aTooltip);
|
||||
NS_IF_ADDREF(*aTooltip = mRootBox->GetDefaultTooltip());
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -98,8 +98,6 @@ public:
|
|||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
|
||||
nsresult Init(nsIContent* aSourceNode, nsIRootBox* aRootBox);
|
||||
nsresult SetDefaultTooltip(nsIContent* aDefaultTooltip);
|
||||
nsresult GetDefaultTooltip(nsIContent** aDefaultTooltip);
|
||||
nsresult AddTooltipSupport(nsIContent* aNode);
|
||||
nsresult RemoveTooltipSupport(nsIContent* aNode);
|
||||
|
||||
|
|
|
@ -224,29 +224,6 @@
|
|||
}
|
||||
]]></handler>
|
||||
|
||||
<handler event="popupshowing">
|
||||
<![CDATA[
|
||||
// fill in the label automatically for the default tooltip
|
||||
if (this.getAttribute("default") == "true") {
|
||||
var label = "";
|
||||
var ttNode = document.tooltipNode;
|
||||
if (ttNode && ttNode.hasAttribute("tooltiptext"))
|
||||
this.label = ttNode.getAttribute("tooltiptext");
|
||||
}
|
||||
|
||||
// This is a special consideration for tree titletips. There is a
|
||||
// case where the user moves the mouse from over the treebody to
|
||||
// completely outside of the window, while passing over a cell that
|
||||
// displays a titletip. This causes the titletip to show, even though
|
||||
// the mouse is not over the corresponding cell, so we need to check
|
||||
// if the titletip was entered by the mouse, and if not, hide it.
|
||||
// XXX commenting this out for now because it doesn't work on Mac
|
||||
// become mouseover isn't fired when the tooltip appears with the mouse over it
|
||||
//if (this.hasAttribute("titletip"))
|
||||
// window.setTimeout(function(me) { if (!me._isMouseOver) me.hidePopup(); }, 100, this);
|
||||
]]>
|
||||
</handler>
|
||||
|
||||
<handler event="popuphiding"><![CDATA[
|
||||
this._isMouseOver = false;
|
||||
this._mouseOutCount = 0;
|
||||
|
|
|
@ -236,29 +236,6 @@
|
|||
}
|
||||
]]></handler>
|
||||
|
||||
<handler event="popupshowing">
|
||||
<![CDATA[
|
||||
// fill in the label automatically for the default tooltip
|
||||
if (this.getAttribute("default") == "true") {
|
||||
var label = "";
|
||||
var ttNode = document.tooltipNode;
|
||||
if (ttNode && ttNode.hasAttribute("tooltiptext"))
|
||||
this.label = ttNode.getAttribute("tooltiptext");
|
||||
}
|
||||
|
||||
// This is a special consideration for tree titletips. There is a
|
||||
// case where the user moves the mouse from over the treebody to
|
||||
// completely outside of the window, while passing over a cell that
|
||||
// displays a titletip. This causes the titletip to show, even though
|
||||
// the mouse is not over the corresponding cell, so we need to check
|
||||
// if the titletip was entered by the mouse, and if not, hide it.
|
||||
// XXX commenting this out for now because it doesn't work on Mac
|
||||
// become mouseover isn't fired when the tooltip appears with the mouse over it
|
||||
//if (this.hasAttribute("titletip"))
|
||||
// window.setTimeout(function(me) { if (!me._isMouseOver) me.hidePopup(); }, 100, this);
|
||||
]]>
|
||||
</handler>
|
||||
|
||||
<handler event="popuphiding"><![CDATA[
|
||||
this._isMouseOver = false;
|
||||
this._mouseOutCount = 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче