mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 294277, Support 'inline' <alert>s, r=aaronr+doronr, a=mkaply, NPOTB
This commit is contained in:
parent
c1d82771b1
commit
689cb343a9
@ -165,6 +165,7 @@ private:
|
||||
nsresult HandleModalAndModelessMessage(nsIDOMDocument* aDoc, nsAString& aLevel);
|
||||
void CloneNode(nsIDOMNode* aSrc, nsIDOMNode** aTarget);
|
||||
void AppendCSSOptions(nsIDOMViewCSS* aViewCSS, nsAString& aOptions);
|
||||
PRBool HandleInlineAlert(nsIDOMEvent* aEvent);
|
||||
nsresult ConstructMessageWindowURL(nsAString& aData,
|
||||
PRBool aIsLink,
|
||||
/*out*/ nsAString& aURL);
|
||||
@ -209,11 +210,13 @@ nsXFormsMessageElement::OnCreated(nsIXTFXMLVisualWrapper *aWrapper)
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
mElement->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
domDoc->CreateElementNS(NS_LITERAL_STRING(NS_NAMESPACE_XHTML),
|
||||
NS_LITERAL_STRING("div"),
|
||||
mType == eType_Alert
|
||||
? NS_LITERAL_STRING("span")
|
||||
: NS_LITERAL_STRING("div"),
|
||||
getter_AddRefs(mVisualElement));
|
||||
if (mVisualElement)
|
||||
mVisualElement->SetAttribute(NS_LITERAL_STRING("style"),
|
||||
NS_LITERAL_STRING(EPHEMERAL_STYLE_HIDDEN));
|
||||
if (mVisualElement && mType != eType_Alert)
|
||||
mVisualElement->SetAttribute(NS_LITERAL_STRING("style"),
|
||||
NS_LITERAL_STRING(EPHEMERAL_STYLE_HIDDEN));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -394,6 +397,9 @@ nsXFormsMessageElement::HandleAction(nsIDOMEvent* aEvent,
|
||||
level.AssignLiteral("modeless");
|
||||
break;
|
||||
case eType_Alert:
|
||||
if (HandleInlineAlert(aEvent))
|
||||
return NS_OK;
|
||||
|
||||
level.AssignLiteral("modal");
|
||||
break;
|
||||
}
|
||||
@ -409,6 +415,59 @@ nsXFormsMessageElement::HandleAction(nsIDOMEvent* aEvent,
|
||||
: HandleModalAndModelessMessage(doc, level);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsXFormsMessageElement::HandleInlineAlert(nsIDOMEvent* aEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> doc;
|
||||
mElement->GetOwnerDocument(getter_AddRefs(doc));
|
||||
|
||||
nsCOMPtr<nsIDOMDocumentView> dview(do_QueryInterface(doc));
|
||||
if (!dview)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMAbstractView> aview;
|
||||
dview->GetDefaultView(getter_AddRefs(aview));
|
||||
if (!aview)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> internal(do_QueryInterface(aview));
|
||||
if (!internal)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMViewCSS> cssView(do_QueryInterface(internal));
|
||||
if (!cssView)
|
||||
return PR_FALSE;
|
||||
|
||||
nsAutoString tmp;
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> styles;
|
||||
cssView->GetComputedStyle(mElement, tmp, getter_AddRefs(styles));
|
||||
nsCOMPtr<nsIDOMCSSValue> display;
|
||||
styles->GetPropertyCSSValue(NS_LITERAL_STRING("display"),
|
||||
getter_AddRefs(display));
|
||||
if (display) {
|
||||
nsCOMPtr<nsIDOMCSSPrimitiveValue> displayValue(do_QueryInterface(display));
|
||||
if (displayValue) {
|
||||
nsAutoString type;
|
||||
displayValue->GetStringValue(type);
|
||||
if (type.EqualsLiteral("none"))
|
||||
return PR_FALSE;
|
||||
|
||||
nsAutoString instanceData;
|
||||
PRBool hasBinding = nsXFormsUtils::GetSingleNodeBindingValue(mElement,
|
||||
instanceData);
|
||||
if (hasBinding) {
|
||||
nsCOMPtr<nsIDOM3Node> visualElement3(do_QueryInterface(mVisualElement));
|
||||
if (visualElement3) {
|
||||
visualElement3->SetTextContent(instanceData);
|
||||
}
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXFormsMessageElement::HandleEphemeralMessage(nsIDOMDocument* aDoc,
|
||||
nsIDOMEvent* aEvent)
|
||||
|
@ -520,15 +520,15 @@ nsXFormsModelElement::SetSingleState(nsIDOMElement *aElement,
|
||||
{
|
||||
nsXFormsEvent event = aState ? aOnEvent : (nsXFormsEvent) (aOnEvent + 1);
|
||||
|
||||
// Dispatch event
|
||||
nsXFormsUtils::DispatchEvent(aElement, event);
|
||||
|
||||
// Set pseudo class
|
||||
///
|
||||
/// @bug Set via attributes right now. Bug 271720. (XXX)
|
||||
aElement->SetAttribute(kStateAttributes[aState ? aAttributePos : aAttributePos + 1],
|
||||
NS_LITERAL_STRING("1"));
|
||||
aElement->RemoveAttribute(kStateAttributes[aState ? aAttributePos + 1 : aAttributePos]);
|
||||
|
||||
// Dispatch event
|
||||
nsXFormsUtils::DispatchEvent(aElement, event);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -52,3 +52,7 @@ message[level="ephemeral"], hint {
|
||||
visibility: hidden !important;
|
||||
position: absolute !important;
|
||||
}
|
||||
|
||||
alert {
|
||||
display: none;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user