2005-08-20 11:13:18 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2002
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2005-08-20 11:13:39 +04:00
|
|
|
* Brian Ryner <bryner@brianryner.com> (Original Author)
|
2005-08-20 11:13:18 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include "nsNativeTheme.h"
|
2009-04-02 01:59:02 +04:00
|
|
|
#include "nsIWidget.h"
|
2005-08-20 11:13:18 +04:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIPresShell.h"
|
2005-08-20 11:14:04 +04:00
|
|
|
#include "nsPresContext.h"
|
2011-04-21 21:35:52 +04:00
|
|
|
#include "nsEventStateManager.h"
|
2005-08-20 11:13:18 +04:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
2011-07-01 14:20:45 +04:00
|
|
|
#include "nsIDOMXULMenuListElement.h"
|
2005-08-20 11:13:18 +04:00
|
|
|
#include "nsThemeConstants.h"
|
|
|
|
#include "nsIComponentManager.h"
|
2010-04-21 18:53:42 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
2011-05-06 14:00:30 +04:00
|
|
|
#include "nsProgressFrame.h"
|
2011-07-11 18:05:07 +04:00
|
|
|
#include "nsMenuFrame.h"
|
2011-07-20 23:18:54 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2012-03-07 19:29:21 +04:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "mozilla/Services.h"
|
2005-08-20 11:13:18 +04:00
|
|
|
|
|
|
|
nsNativeTheme::nsNativeTheme()
|
2010-11-13 11:19:38 +03:00
|
|
|
: mAnimatedContentTimeout(PR_UINT32_MAX)
|
2005-08-20 11:13:18 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-03-07 19:29:21 +04:00
|
|
|
NS_IMPL_ISUPPORTS2(nsNativeTheme, nsITimerCallback, nsIObserver)
|
2010-11-13 11:19:38 +03:00
|
|
|
|
2005-08-20 11:13:35 +04:00
|
|
|
nsIPresShell *
|
2005-08-20 11:14:11 +04:00
|
|
|
nsNativeTheme::GetPresShell(nsIFrame* aFrame)
|
2005-08-20 11:13:18 +04:00
|
|
|
{
|
|
|
|
if (!aFrame)
|
2005-08-20 11:13:35 +04:00
|
|
|
return nsnull;
|
2005-08-20 11:13:18 +04:00
|
|
|
|
2005-08-20 11:14:11 +04:00
|
|
|
// this is a workaround for the egcs 1.1.2 not inliningg
|
|
|
|
// aFrame->GetPresContext(), which causes an undefined symbol
|
|
|
|
nsPresContext *context = aFrame->GetStyleContext()->GetRuleNode()->GetPresContext();
|
|
|
|
return context ? context->GetPresShell() : nsnull;
|
2005-08-20 11:13:18 +04:00
|
|
|
}
|
|
|
|
|
2010-10-20 15:26:32 +04:00
|
|
|
nsEventStates
|
2005-08-20 11:13:20 +04:00
|
|
|
nsNativeTheme::GetContentState(nsIFrame* aFrame, PRUint8 aWidgetType)
|
2005-08-20 11:13:18 +04:00
|
|
|
{
|
|
|
|
if (!aFrame)
|
2010-10-20 15:26:32 +04:00
|
|
|
return nsEventStates();
|
2005-08-20 11:13:18 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isXULCheckboxRadio =
|
2007-05-09 23:17:17 +04:00
|
|
|
(aWidgetType == NS_THEME_CHECKBOX ||
|
2008-11-03 16:12:59 +03:00
|
|
|
aWidgetType == NS_THEME_RADIO) &&
|
2009-08-25 00:02:07 +04:00
|
|
|
aFrame->GetContent()->IsXUL();
|
2005-08-20 11:13:56 +04:00
|
|
|
if (isXULCheckboxRadio)
|
2005-08-20 11:13:33 +04:00
|
|
|
aFrame = aFrame->GetParent();
|
2005-08-20 11:13:20 +04:00
|
|
|
|
2009-04-14 21:22:04 +04:00
|
|
|
if (!aFrame->GetContent())
|
2010-10-20 15:26:32 +04:00
|
|
|
return nsEventStates();
|
2009-04-14 21:22:04 +04:00
|
|
|
|
2005-08-20 11:14:11 +04:00
|
|
|
nsIPresShell *shell = GetPresShell(aFrame);
|
2005-08-20 11:13:18 +04:00
|
|
|
if (!shell)
|
2010-10-20 15:26:32 +04:00
|
|
|
return nsEventStates();
|
2005-08-20 11:13:18 +04:00
|
|
|
|
2011-06-01 05:46:56 +04:00
|
|
|
nsIContent* frameContent = aFrame->GetContent();
|
|
|
|
nsEventStates flags;
|
|
|
|
if (frameContent->IsElement()) {
|
|
|
|
flags = frameContent->AsElement()->State();
|
|
|
|
}
|
2005-08-20 11:13:20 +04:00
|
|
|
|
2008-11-03 16:12:59 +03:00
|
|
|
if (isXULCheckboxRadio && aWidgetType == NS_THEME_RADIO) {
|
2005-08-20 11:13:20 +04:00
|
|
|
if (IsFocused(aFrame))
|
|
|
|
flags |= NS_EVENT_STATE_FOCUS;
|
|
|
|
}
|
2010-04-21 18:53:42 +04:00
|
|
|
|
|
|
|
// On Windows and Mac, only draw focus rings if they should be shown. This
|
|
|
|
// means that focus rings are only shown once the keyboard has been used to
|
|
|
|
// focus something in the window.
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
// Mac always draws focus rings for textboxes and lists.
|
|
|
|
if (aWidgetType == NS_THEME_TEXTFIELD ||
|
|
|
|
aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
|
|
|
|
aWidgetType == NS_THEME_SEARCHFIELD ||
|
|
|
|
aWidgetType == NS_THEME_LISTBOX) {
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
// On Windows, focused buttons are always drawn as such by the native theme.
|
|
|
|
if (aWidgetType == NS_THEME_BUTTON)
|
|
|
|
return flags;
|
|
|
|
#endif
|
|
|
|
#if defined(XP_MACOSX) || defined(XP_WIN)
|
2011-10-18 14:53:36 +04:00
|
|
|
nsIDocument* doc = aFrame->GetContent()->OwnerDoc();
|
2011-10-18 15:19:44 +04:00
|
|
|
nsPIDOMWindow* window = doc->GetWindow();
|
|
|
|
if (window && !window->ShouldShowFocusRing())
|
|
|
|
flags &= ~NS_EVENT_STATE_FOCUS;
|
2010-04-21 18:53:42 +04:00
|
|
|
#endif
|
2005-08-20 11:13:20 +04:00
|
|
|
|
2005-08-20 11:13:18 +04:00
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2005-08-20 11:13:18 +04:00
|
|
|
nsNativeTheme::CheckBooleanAttr(nsIFrame* aFrame, nsIAtom* aAtom)
|
|
|
|
{
|
|
|
|
if (!aFrame)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2005-08-20 11:13:18 +04:00
|
|
|
|
2005-08-20 11:13:33 +04:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2009-04-14 21:22:04 +04:00
|
|
|
if (!content)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-04-14 21:22:04 +04:00
|
|
|
|
2009-08-25 00:02:07 +04:00
|
|
|
if (content->IsHTML())
|
2005-08-20 11:13:57 +04:00
|
|
|
return content->HasAttr(kNameSpaceID_None, aAtom);
|
2005-08-20 11:13:18 +04:00
|
|
|
|
|
|
|
// For XML/XUL elements, an attribute must be equal to the literal
|
|
|
|
// string "true" to be counted as true. An empty string should _not_
|
|
|
|
// be counted as true.
|
2005-10-28 15:25:24 +04:00
|
|
|
return content->AttrValueIs(kNameSpaceID_None, aAtom,
|
|
|
|
NS_LITERAL_STRING("true"), eCaseMatters);
|
2005-08-20 11:13:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32
|
2008-03-27 08:36:20 +03:00
|
|
|
nsNativeTheme::CheckIntAttr(nsIFrame* aFrame, nsIAtom* aAtom, PRInt32 defaultValue)
|
2005-08-20 11:13:18 +04:00
|
|
|
{
|
|
|
|
if (!aFrame)
|
2008-03-27 08:36:20 +03:00
|
|
|
return defaultValue;
|
2005-08-20 11:13:18 +04:00
|
|
|
|
|
|
|
nsAutoString attr;
|
2005-08-20 11:13:33 +04:00
|
|
|
aFrame->GetContent()->GetAttr(kNameSpaceID_None, aAtom, attr);
|
2005-08-20 11:13:22 +04:00
|
|
|
PRInt32 err, value = attr.ToInteger(&err);
|
2008-03-27 08:36:20 +03:00
|
|
|
if (attr.IsEmpty() || NS_FAILED(err))
|
|
|
|
return defaultValue;
|
2005-08-20 11:13:18 +04:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
|
|
|
nsNativeTheme::GetCheckedOrSelected(nsIFrame* aFrame, bool aCheckSelected)
|
2005-08-20 11:13:18 +04:00
|
|
|
{
|
|
|
|
if (!aFrame)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2005-08-20 11:13:18 +04:00
|
|
|
|
2005-08-20 11:13:33 +04:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2005-08-20 11:13:18 +04:00
|
|
|
|
2009-08-25 00:02:07 +04:00
|
|
|
if (content->IsXUL()) {
|
2005-08-20 11:13:18 +04:00
|
|
|
// For a XUL checkbox or radio button, the state of the parent determines
|
|
|
|
// the checked state
|
2005-08-20 11:13:33 +04:00
|
|
|
aFrame = aFrame->GetParent();
|
2005-08-20 11:13:18 +04:00
|
|
|
} else {
|
|
|
|
// Check for an HTML input element
|
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> inputElt = do_QueryInterface(content);
|
|
|
|
if (inputElt) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool checked;
|
2005-08-20 11:13:18 +04:00
|
|
|
inputElt->GetChecked(&checked);
|
|
|
|
return checked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-14 22:11:22 +04:00
|
|
|
return CheckBooleanAttr(aFrame, aCheckSelected ? nsGkAtoms::selected
|
|
|
|
: nsGkAtoms::checked);
|
2005-08-20 11:13:18 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-08-11 01:23:50 +04:00
|
|
|
nsNativeTheme::IsButtonTypeMenu(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (!aFrame)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-11 01:23:50 +04:00
|
|
|
|
|
|
|
nsIContent* content = aFrame->GetContent();
|
2011-10-14 22:11:22 +04:00
|
|
|
return content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
2009-08-11 01:23:50 +04:00
|
|
|
NS_LITERAL_STRING("menu"), eCaseMatters);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-08-08 18:42:45 +04:00
|
|
|
nsNativeTheme::IsPressedButton(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsEventStates eventState = GetContentState(aFrame, NS_THEME_TOOLBAR_BUTTON);
|
|
|
|
if (IsDisabled(aFrame, eventState))
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-08-08 18:42:45 +04:00
|
|
|
|
|
|
|
return IsOpenButton(aFrame) ||
|
|
|
|
eventState.HasAllStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_HOVER);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-01-30 10:19:41 +03:00
|
|
|
nsNativeTheme::GetIndeterminate(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (!aFrame)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-01-30 10:19:41 +03:00
|
|
|
|
|
|
|
nsIContent* content = aFrame->GetContent();
|
|
|
|
|
2009-08-25 00:02:07 +04:00
|
|
|
if (content->IsXUL()) {
|
2009-01-30 10:19:41 +03:00
|
|
|
// For a XUL checkbox or radio button, the state of the parent determines
|
|
|
|
// the state
|
2011-10-14 22:11:22 +04:00
|
|
|
return CheckBooleanAttr(aFrame->GetParent(), nsGkAtoms::indeterminate);
|
2009-01-30 10:19:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check for an HTML input element
|
2010-08-05 06:40:18 +04:00
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> inputElt = do_QueryInterface(content);
|
2009-01-30 10:19:41 +03:00
|
|
|
if (inputElt) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool indeterminate;
|
2009-01-30 10:19:41 +03:00
|
|
|
inputElt->GetIndeterminate(&indeterminate);
|
|
|
|
return indeterminate;
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-01-30 10:19:41 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2005-08-20 11:14:04 +04:00
|
|
|
nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame,
|
2005-08-20 11:13:18 +04:00
|
|
|
PRUint8 aWidgetType)
|
|
|
|
{
|
|
|
|
// Check for specific widgets to see if HTML has overridden the style.
|
2010-06-21 16:37:35 +04:00
|
|
|
if (!aFrame)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-06-21 16:37:35 +04:00
|
|
|
|
|
|
|
// Resizers have some special handling, dependent on whether in a scrollable
|
|
|
|
// container or not. If so, use the scrollable container's to determine
|
|
|
|
// whether the style is overriden instead of the resizer. This allows a
|
|
|
|
// non-native transparent resizer to be used instead. Otherwise, we just
|
|
|
|
// fall through and return false.
|
|
|
|
if (aWidgetType == NS_THEME_RESIZER) {
|
|
|
|
nsIFrame* parentFrame = aFrame->GetParent();
|
2011-10-14 22:11:22 +04:00
|
|
|
if (parentFrame && parentFrame->GetType() == nsGkAtoms::scrollFrame) {
|
2010-06-21 16:37:35 +04:00
|
|
|
// if the parent is a scrollframe, the resizer should be native themed
|
|
|
|
// only if the scrollable area doesn't override the widget style.
|
|
|
|
parentFrame = parentFrame->GetParent();
|
|
|
|
if (parentFrame) {
|
|
|
|
return IsWidgetStyled(aPresContext, parentFrame,
|
|
|
|
parentFrame->GetStyleDisplay()->mAppearance);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-06 14:00:30 +04:00
|
|
|
/**
|
|
|
|
* Progress bar appearance should be the same for the bar and the container
|
|
|
|
* frame. nsProgressFrame owns the logic and will tell us what we should do.
|
|
|
|
*/
|
|
|
|
if (aWidgetType == NS_THEME_PROGRESSBAR_CHUNK ||
|
|
|
|
aWidgetType == NS_THEME_PROGRESSBAR) {
|
|
|
|
nsProgressFrame* progressFrame = do_QueryFrame(aWidgetType == NS_THEME_PROGRESSBAR_CHUNK
|
|
|
|
? aFrame->GetParent() : aFrame);
|
|
|
|
if (progressFrame) {
|
|
|
|
return !progressFrame->ShouldUseNativeStyle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-21 16:37:35 +04:00
|
|
|
return (aWidgetType == NS_THEME_BUTTON ||
|
2007-10-09 03:11:01 +04:00
|
|
|
aWidgetType == NS_THEME_TEXTFIELD ||
|
|
|
|
aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
|
|
|
|
aWidgetType == NS_THEME_LISTBOX ||
|
|
|
|
aWidgetType == NS_THEME_DROPDOWN) &&
|
2009-08-25 00:02:07 +04:00
|
|
|
aFrame->GetContent()->IsHTML() &&
|
2008-04-26 03:12:45 +04:00
|
|
|
aPresContext->HasAuthorSpecifiedRules(aFrame,
|
|
|
|
NS_AUTHOR_SPECIFIED_BORDER |
|
2009-04-01 05:07:18 +04:00
|
|
|
NS_AUTHOR_SPECIFIED_BACKGROUND);
|
2008-01-13 07:13:51 +03:00
|
|
|
}
|
|
|
|
|
2010-09-28 05:25:18 +04:00
|
|
|
bool
|
2010-10-20 15:26:32 +04:00
|
|
|
nsNativeTheme::IsDisabled(nsIFrame* aFrame, nsEventStates aEventStates)
|
2010-09-28 05:25:18 +04:00
|
|
|
{
|
|
|
|
if (!aFrame) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIContent* content = aFrame->GetContent();
|
|
|
|
if (!content) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-09-28 05:25:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (content->IsHTML()) {
|
2010-10-20 15:26:32 +04:00
|
|
|
return aEventStates.HasState(NS_EVENT_STATE_DISABLED);
|
2010-09-28 05:25:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// For XML/XUL elements, an attribute must be equal to the literal
|
|
|
|
// string "true" to be counted as true. An empty string should _not_
|
|
|
|
// be counted as true.
|
2011-10-14 22:11:22 +04:00
|
|
|
return content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
|
2010-09-28 05:25:18 +04:00
|
|
|
NS_LITERAL_STRING("true"), eCaseMatters);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2008-11-28 01:14:54 +03:00
|
|
|
nsNativeTheme::IsFrameRTL(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
return aFrame && aFrame->GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
|
|
|
|
}
|
|
|
|
|
2008-01-13 07:13:50 +03:00
|
|
|
// scrollbar button:
|
|
|
|
PRInt32
|
|
|
|
nsNativeTheme::GetScrollbarButtonType(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (!aFrame)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2011-10-14 22:11:22 +04:00
|
|
|
{&nsGkAtoms::scrollbarDownBottom, &nsGkAtoms::scrollbarDownTop,
|
|
|
|
&nsGkAtoms::scrollbarUpBottom, &nsGkAtoms::scrollbarUpTop,
|
2008-01-13 07:13:50 +03:00
|
|
|
nsnull};
|
|
|
|
|
|
|
|
switch (aFrame->GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
2011-10-14 22:11:22 +04:00
|
|
|
nsGkAtoms::sbattr,
|
2008-01-13 07:13:50 +03:00
|
|
|
strings, eCaseMatters)) {
|
|
|
|
case 0: return eScrollbarButton_Down | eScrollbarButton_Bottom;
|
|
|
|
case 1: return eScrollbarButton_Down;
|
|
|
|
case 2: return eScrollbarButton_Bottom;
|
|
|
|
case 3: return eScrollbarButton_UpTop;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-06-09 10:02:30 +04:00
|
|
|
// treeheadercell:
|
|
|
|
nsNativeTheme::TreeSortDirection
|
|
|
|
nsNativeTheme::GetTreeSortDirection(nsIFrame* aFrame)
|
|
|
|
{
|
2010-10-11 02:07:00 +04:00
|
|
|
if (!aFrame || !aFrame->GetContent())
|
2006-06-09 10:02:30 +04:00
|
|
|
return eTreeSortDirection_Natural;
|
|
|
|
|
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2011-10-14 22:11:22 +04:00
|
|
|
{&nsGkAtoms::descending, &nsGkAtoms::ascending, nsnull};
|
2006-06-09 10:02:30 +04:00
|
|
|
switch (aFrame->GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
2011-10-14 22:11:22 +04:00
|
|
|
nsGkAtoms::sortDirection,
|
2006-06-09 10:02:30 +04:00
|
|
|
strings, eCaseMatters)) {
|
|
|
|
case 0: return eTreeSortDirection_Descending;
|
|
|
|
case 1: return eTreeSortDirection_Ascending;
|
|
|
|
}
|
|
|
|
|
|
|
|
return eTreeSortDirection_Natural;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2008-11-28 01:14:54 +03:00
|
|
|
nsNativeTheme::IsLastTreeHeaderCell(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (!aFrame)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2008-11-28 01:14:54 +03:00
|
|
|
|
|
|
|
// A tree column picker is always the last header cell.
|
2011-10-14 22:11:22 +04:00
|
|
|
if (aFrame->GetContent()->Tag() == nsGkAtoms::treecolpicker)
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2008-11-28 01:14:54 +03:00
|
|
|
|
|
|
|
// Find the parent tree.
|
|
|
|
nsIContent* parent = aFrame->GetContent()->GetParent();
|
2011-10-14 22:11:22 +04:00
|
|
|
while (parent && parent->Tag() != nsGkAtoms::tree) {
|
2008-11-28 01:14:54 +03:00
|
|
|
parent = parent->GetParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the column picker is visible, this can't be the last column.
|
2011-10-14 22:11:22 +04:00
|
|
|
if (parent && !parent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidecolumnpicker,
|
2008-11-28 01:14:54 +03:00
|
|
|
NS_LITERAL_STRING("true"), eCaseMatters))
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2008-11-28 01:14:54 +03:00
|
|
|
|
|
|
|
while ((aFrame = aFrame->GetNextSibling())) {
|
|
|
|
if (aFrame->GetRect().width > 0)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2008-11-28 01:14:54 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2008-11-28 01:14:54 +03:00
|
|
|
}
|
|
|
|
|
2006-06-09 10:02:30 +04:00
|
|
|
// tab:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2006-06-09 10:02:30 +04:00
|
|
|
nsNativeTheme::IsBottomTab(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (!aFrame)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2006-06-09 10:02:30 +04:00
|
|
|
|
|
|
|
nsAutoString classStr;
|
2011-10-14 22:11:22 +04:00
|
|
|
aFrame->GetContent()->GetAttr(kNameSpaceID_None, nsGkAtoms::_class, classStr);
|
2006-06-09 10:02:30 +04:00
|
|
|
return !classStr.IsEmpty() && classStr.Find("tab-bottom") != kNotFound;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2006-08-31 01:47:16 +04:00
|
|
|
nsNativeTheme::IsFirstTab(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (!aFrame)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2006-08-31 01:47:16 +04:00
|
|
|
|
2011-08-25 00:54:30 +04:00
|
|
|
nsIFrame* first = aFrame->GetParent()->GetFirstPrincipalChild();
|
2009-01-03 00:02:50 +03:00
|
|
|
while (first) {
|
2011-10-14 22:11:22 +04:00
|
|
|
if (first->GetRect().width > 0 && first->GetContent()->Tag() == nsGkAtoms::tab)
|
2009-01-03 00:02:50 +03:00
|
|
|
return (first == aFrame);
|
|
|
|
first = first->GetNextSibling();
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2006-08-31 01:47:16 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2007-12-21 14:17:01 +03:00
|
|
|
nsNativeTheme::IsHorizontal(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (!aFrame)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2007-12-21 14:17:01 +03:00
|
|
|
|
2011-10-14 22:11:22 +04:00
|
|
|
return !aFrame->GetContent()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::orient,
|
|
|
|
nsGkAtoms::vertical,
|
2007-12-21 14:17:01 +03:00
|
|
|
eCaseMatters);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-08-08 19:38:57 +04:00
|
|
|
nsNativeTheme::IsNextToSelectedTab(nsIFrame* aFrame, PRInt32 aOffset)
|
|
|
|
{
|
|
|
|
if (!aFrame)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-08-08 19:38:57 +04:00
|
|
|
|
|
|
|
if (aOffset == 0)
|
|
|
|
return IsSelectedTab(aFrame);
|
|
|
|
|
|
|
|
PRInt32 thisTabIndex = -1, selectedTabIndex = -1;
|
|
|
|
|
2011-08-25 00:54:30 +04:00
|
|
|
nsIFrame* currentTab = aFrame->GetParent()->GetFirstPrincipalChild();
|
2011-08-08 19:38:57 +04:00
|
|
|
for (PRInt32 i = 0; currentTab; currentTab = currentTab->GetNextSibling()) {
|
|
|
|
if (currentTab->GetRect().width == 0)
|
|
|
|
continue;
|
|
|
|
if (aFrame == currentTab)
|
|
|
|
thisTabIndex = i;
|
|
|
|
if (IsSelectedTab(currentTab))
|
|
|
|
selectedTabIndex = i;
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thisTabIndex == -1 || selectedTabIndex == -1)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-08-08 19:38:57 +04:00
|
|
|
|
|
|
|
return (thisTabIndex - selectedTabIndex == aOffset);
|
|
|
|
}
|
|
|
|
|
2006-06-09 10:02:30 +04:00
|
|
|
// progressbar:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-03-01 05:06:22 +03:00
|
|
|
nsNativeTheme::IsIndeterminateProgress(nsIFrame* aFrame,
|
|
|
|
nsEventStates aEventStates)
|
2006-06-09 10:02:30 +04:00
|
|
|
{
|
2011-08-04 10:55:28 +04:00
|
|
|
if (!aFrame || !aFrame->GetContent())
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2006-06-09 10:02:30 +04:00
|
|
|
|
2011-10-14 22:11:22 +04:00
|
|
|
if (aFrame->GetContent()->IsHTML(nsGkAtoms::progress)) {
|
2011-03-01 05:06:22 +03:00
|
|
|
return aEventStates.HasState(NS_EVENT_STATE_INDETERMINATE);
|
|
|
|
}
|
|
|
|
|
2011-10-14 22:11:22 +04:00
|
|
|
return aFrame->GetContent()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::mode,
|
2006-06-09 10:02:30 +04:00
|
|
|
NS_LITERAL_STRING("undetermined"),
|
|
|
|
eCaseMatters);
|
|
|
|
}
|
2009-01-12 22:23:51 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-05-17 20:39:22 +04:00
|
|
|
nsNativeTheme::IsVerticalProgress(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
return aFrame &&
|
|
|
|
aFrame->GetStyleDisplay()->mOrient == NS_STYLE_ORIENT_VERTICAL;
|
|
|
|
}
|
|
|
|
|
2009-01-12 22:23:51 +03:00
|
|
|
// menupopup:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
|
|
|
nsNativeTheme::IsSubmenu(nsIFrame* aFrame, bool* aLeftOfParent)
|
2009-01-12 22:23:51 +03:00
|
|
|
{
|
|
|
|
if (!aFrame)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-01-12 22:23:51 +03:00
|
|
|
|
|
|
|
nsIContent* parentContent = aFrame->GetContent()->GetParent();
|
2011-10-14 22:11:22 +04:00
|
|
|
if (!parentContent || parentContent->Tag() != nsGkAtoms::menu)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-01-12 22:23:51 +03:00
|
|
|
|
|
|
|
nsIFrame* parent = aFrame;
|
|
|
|
while ((parent = parent->GetParent())) {
|
|
|
|
if (parent->GetContent() == parentContent) {
|
|
|
|
if (aLeftOfParent) {
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntRect selfBounds, parentBounds;
|
2010-07-02 23:11:04 +04:00
|
|
|
aFrame->GetNearestWidget()->GetScreenBounds(selfBounds);
|
|
|
|
parent->GetNearestWidget()->GetScreenBounds(parentBounds);
|
2009-01-12 22:23:51 +03:00
|
|
|
*aLeftOfParent = selfBounds.x < parentBounds.x;
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-01-12 22:23:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-01-12 22:23:51 +03:00
|
|
|
}
|
2010-11-13 11:19:38 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-06-25 01:00:46 +04:00
|
|
|
nsNativeTheme::IsRegularMenuItem(nsIFrame *aFrame)
|
|
|
|
{
|
2011-07-11 18:05:07 +04:00
|
|
|
nsMenuFrame *menuFrame = do_QueryFrame(aFrame);
|
2011-06-25 01:00:46 +04:00
|
|
|
return !(menuFrame && (menuFrame->IsOnMenuBar() ||
|
|
|
|
menuFrame->GetParentMenuListType() != eNotMenuList));
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-07-01 14:20:45 +04:00
|
|
|
nsNativeTheme::IsMenuListEditable(nsIFrame *aFrame)
|
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isEditable = false;
|
2011-07-01 14:20:45 +04:00
|
|
|
nsCOMPtr<nsIDOMXULMenuListElement> menulist = do_QueryInterface(aFrame->GetContent());
|
|
|
|
if (menulist)
|
|
|
|
menulist->GetEditable(&isEditable);
|
|
|
|
return isEditable;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-11-13 11:19:38 +03:00
|
|
|
nsNativeTheme::QueueAnimatedContentForRefresh(nsIContent* aContent,
|
|
|
|
PRUint32 aMinimumFrameRate)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aContent, "Null pointer!");
|
|
|
|
NS_ASSERTION(aMinimumFrameRate, "aMinimumFrameRate must be non-zero!");
|
|
|
|
NS_ASSERTION(aMinimumFrameRate <= 1000,
|
|
|
|
"aMinimumFrameRate must be less than 1000!");
|
|
|
|
|
2011-06-22 00:48:18 +04:00
|
|
|
PRUint32 timeout = 1000 / aMinimumFrameRate;
|
2011-06-02 16:56:50 +04:00
|
|
|
timeout = NS_MIN(mAnimatedContentTimeout, timeout);
|
2010-11-13 11:19:38 +03:00
|
|
|
|
|
|
|
if (!mAnimatedContentTimer) {
|
|
|
|
mAnimatedContentTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_ENSURE_TRUE(mAnimatedContentTimer, false);
|
2010-11-13 11:19:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mAnimatedContentList.IsEmpty() || timeout != mAnimatedContentTimeout) {
|
|
|
|
nsresult rv;
|
|
|
|
if (!mAnimatedContentList.IsEmpty()) {
|
|
|
|
rv = mAnimatedContentTimer->Cancel();
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2010-11-13 11:19:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
rv = mAnimatedContentTimer->InitWithCallback(this, timeout,
|
|
|
|
nsITimer::TYPE_ONE_SHOT);
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2010-11-13 11:19:38 +03:00
|
|
|
|
|
|
|
mAnimatedContentTimeout = timeout;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mAnimatedContentList.AppendElement(aContent)) {
|
|
|
|
NS_WARNING("Out of memory!");
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-11-13 11:19:38 +03:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2010-11-13 11:19:38 +03:00
|
|
|
}
|
|
|
|
|
2012-03-07 19:29:21 +04:00
|
|
|
inline bool
|
|
|
|
IsFadeIn(nsNativeTheme::FadeState aState)
|
|
|
|
{
|
|
|
|
return (aState == nsNativeTheme::FADE_IN ||
|
|
|
|
aState == nsNativeTheme::FADE_IN_FINISHED);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
IsFadeOut(nsNativeTheme::FadeState aState)
|
|
|
|
{
|
|
|
|
return (aState == nsNativeTheme::FADE_OUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsNativeTheme::QueueAnimatedContentRefreshForFade(nsIContent* aContent,
|
|
|
|
FadeState aFadeDirection,
|
|
|
|
PRUint32 aMinimumFrameRate,
|
|
|
|
PRUint32 aMilliseconds,
|
|
|
|
PRUint32 aUserData)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aContent, "Null pointer!");
|
|
|
|
NS_ASSERTION((aFadeDirection == FADE_IN ||
|
|
|
|
aFadeDirection == FADE_OUT), "Bad initial fade direction.");
|
|
|
|
|
|
|
|
// Initialize our hash table and setup an observer for freeing its contents
|
|
|
|
// on shutdown.
|
|
|
|
if (NS_FAILED(InitFadeList()))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Note, QueueAnimatedContentForRefresh failures in here can result in
|
|
|
|
// content getting stuck in mAnimatedFadesList until shutdown, so we
|
|
|
|
// warn loudly. Generally this should never happen.
|
|
|
|
|
|
|
|
FadeData* pFade = mAnimatedFadesList.Get(aContent);
|
|
|
|
if (pFade) {
|
|
|
|
// Update the user data
|
|
|
|
pFade->SetUserData(aUserData);
|
|
|
|
|
|
|
|
// Check for direction changes and update our fade data accordingly.
|
|
|
|
if (IsFadeIn(pFade->GetState()) != IsFadeIn(aFadeDirection)) {
|
|
|
|
if (pFade->GetState() != FADE_IN_FINISHED) {
|
|
|
|
// The amount of time we spent getting here equals the amount of
|
|
|
|
// time we spend getting back out.
|
|
|
|
pFade->Reset(pFade->TimeoutUsed(), aFadeDirection);
|
|
|
|
} else {
|
|
|
|
// Reset to transition timeout passed in.
|
|
|
|
//PRUint32 timeout =
|
|
|
|
// PR_IntervalToMilliseconds(PR_IntervalNow()) + aMilliseconds;
|
|
|
|
//pFade->Reset(timeout, aFadeDirection);
|
|
|
|
pFade->Reset(TimeDuration::FromMilliseconds(aMilliseconds),
|
|
|
|
aFadeDirection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for a timeout
|
|
|
|
if (pFade->GetTimeout() < TimeStamp::Now()) {
|
|
|
|
// If timed out and it's a fade up, set state to finished. We keep the
|
|
|
|
// fade data around until a corresponding fade out completes or the
|
|
|
|
// underlying frame is destroyed.
|
|
|
|
if (IsFadeIn(pFade->GetState())) {
|
|
|
|
pFade->FadeInFinished();
|
|
|
|
// Create a heartbeat (1 sec) animation timer so if the underlying
|
|
|
|
// frame is destroyed, Notify will free the content.
|
|
|
|
if (!QueueAnimatedContentForRefresh(aContent, 1)) {
|
|
|
|
NS_WARNING("QueueAnimatedContentForRefresh failed???");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (IsFadeOut(pFade->GetState())) {
|
|
|
|
// If timed out and it's a fade out, clear it, we're done.
|
|
|
|
mAnimatedFadesList.Remove(aContent);
|
|
|
|
// Fire one last time to get the base graphic painted.
|
|
|
|
if (!QueueAnimatedContentForRefresh(aContent, aMinimumFrameRate)) {
|
|
|
|
NS_WARNING("QueueAnimatedContentForRefresh failed???");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// fading..
|
|
|
|
if (!QueueAnimatedContentForRefresh(aContent, aMinimumFrameRate)) {
|
|
|
|
NS_WARNING("QueueAnimatedContentForRefresh failed???");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we don't have a fade put together a FadeData, store it in
|
|
|
|
// mAnimatedFadesList, and kick things off.
|
|
|
|
TimeStamp timeout = TimeStamp::Now() +
|
|
|
|
TimeDuration::FromMilliseconds(aMilliseconds);
|
|
|
|
nsAutoPtr<FadeData> newFade(new FadeData(timeout, aFadeDirection, aUserData));
|
|
|
|
if (!newFade) {
|
|
|
|
NS_WARNING("Out of memory!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Call QueueAnimatedContentForRefresh to kick off the fade animation.
|
|
|
|
if (!QueueAnimatedContentForRefresh(aContent, aMinimumFrameRate)) {
|
|
|
|
NS_WARNING("QueueAnimatedContentForRefresh failed???");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mAnimatedFadesList.Put(aContent, newFade);
|
|
|
|
newFade.forget();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// mAnimatedFadesList management
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsNativeTheme::InitFadeList()
|
|
|
|
{
|
|
|
|
if (mAnimatedFadesList.IsInitialized())
|
|
|
|
return NS_OK;
|
|
|
|
if (!mAnimatedFadesList.Init())
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
nsCOMPtr<nsIObserverService> obsSvc =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
nsresult rv = NS_ERROR_UNEXPECTED;
|
|
|
|
if (obsSvc) {
|
|
|
|
rv = obsSvc->AddObserver(this, NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID, false);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsNativeTheme::Observe(nsISupports* aSubject, const char* aTopic,
|
|
|
|
const PRUnichar* aData)
|
|
|
|
{
|
|
|
|
if (strcmp(aTopic, NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID) == 0) {
|
|
|
|
mAnimatedFadesList.Clear();
|
|
|
|
nsCOMPtr<nsIObserverService> obsSvc =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
nsresult rv = NS_ERROR_UNEXPECTED;
|
|
|
|
if (obsSvc) {
|
|
|
|
rv = obsSvc->RemoveObserver(this, NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID);
|
|
|
|
}
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv),
|
|
|
|
"nsNativeTheme RemoveObserver failed, this may cause a leak.");
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// mAnimatedContentTimer callback for QueueAnimatedContentForRefresh
|
|
|
|
|
2010-11-13 11:19:38 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsNativeTheme::Notify(nsITimer* aTimer)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aTimer == mAnimatedContentTimer, "Wrong timer!");
|
|
|
|
|
|
|
|
// XXX Assumes that calling nsIFrame::Invalidate won't reenter
|
|
|
|
// QueueAnimatedContentForRefresh.
|
|
|
|
|
|
|
|
PRUint32 count = mAnimatedContentList.Length();
|
|
|
|
for (PRUint32 index = 0; index < count; index++) {
|
|
|
|
nsIFrame* frame = mAnimatedContentList[index]->GetPrimaryFrame();
|
|
|
|
if (frame) {
|
|
|
|
frame->InvalidateOverflowRect();
|
2012-03-07 19:29:21 +04:00
|
|
|
} else {
|
|
|
|
// If this content has fade data associated with it, and the
|
|
|
|
// frame has gone away, free the data and cancel the fade.
|
|
|
|
if (mAnimatedFadesList.IsInitialized()) {
|
|
|
|
mAnimatedFadesList.Remove(mAnimatedContentList[index]);
|
|
|
|
}
|
2010-11-13 11:19:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mAnimatedContentList.Clear();
|
|
|
|
mAnimatedContentTimeout = PR_UINT32_MAX;
|
2012-03-07 19:29:21 +04:00
|
|
|
|
2010-11-13 11:19:38 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-08-08 18:42:45 +04:00
|
|
|
|
2012-03-07 19:29:21 +04:00
|
|
|
// Fade helpers
|
|
|
|
|
|
|
|
nsNativeTheme::FadeData*
|
|
|
|
nsNativeTheme::GetFade(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
if (!aContent || !mAnimatedFadesList.IsInitialized())
|
|
|
|
return nsnull;
|
|
|
|
return mAnimatedFadesList.Get(reinterpret_cast<nsISupports*>(aContent));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsNativeTheme::FadeState
|
|
|
|
nsNativeTheme::GetFadeState(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
FadeData* pFade = GetFade(aContent);
|
|
|
|
if (!pFade)
|
|
|
|
return FADE_NOTACTIVE;
|
|
|
|
return pFade->GetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32
|
|
|
|
nsNativeTheme::GetFadeTicks(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
FadeData* pFade = GetFade(aContent);
|
|
|
|
if (!pFade)
|
|
|
|
return 0;
|
|
|
|
return pFade->GetTicks();
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
nsNativeTheme::GetFadeAlpha(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
return ((double)GetFadeTicks(aContent))/TICK_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32
|
|
|
|
nsNativeTheme::GetFadeUserData(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
FadeData* pFade = GetFade(aContent);
|
|
|
|
if (!pFade)
|
|
|
|
return 0;
|
|
|
|
return pFade->GetUserData();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsNativeTheme::SetFadeUserData(nsIContent* aContent, PRUint32 aUserData)
|
|
|
|
{
|
|
|
|
FadeData* pFade = GetFade(aContent);
|
|
|
|
if (pFade) {
|
|
|
|
pFade->SetUserData(aUserData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsNativeTheme::CancelFade(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
if (aContent && mAnimatedFadesList.IsInitialized()) {
|
|
|
|
mAnimatedFadesList.Remove(reinterpret_cast<nsISupports*>(aContent));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsNativeTheme::FinishFadeIn(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
FadeData* pFade = GetFade(aContent);
|
|
|
|
if (pFade) {
|
|
|
|
pFade->FadeInFinished();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-08 18:42:45 +04:00
|
|
|
nsIFrame*
|
|
|
|
nsNativeTheme::GetAdjacentSiblingFrameWithSameAppearance(nsIFrame* aFrame,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aNextSibling)
|
2011-08-08 18:42:45 +04:00
|
|
|
{
|
|
|
|
if (!aFrame)
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
// Find the next visible sibling.
|
|
|
|
nsIFrame* sibling = aFrame;
|
|
|
|
do {
|
|
|
|
sibling = aNextSibling ? sibling->GetNextSibling() : sibling->GetPrevSibling();
|
|
|
|
} while (sibling && sibling->GetRect().width == 0);
|
|
|
|
|
|
|
|
// Check same appearance and adjacency.
|
|
|
|
if (!sibling ||
|
|
|
|
sibling->GetStyleDisplay()->mAppearance != aFrame->GetStyleDisplay()->mAppearance ||
|
|
|
|
(sibling->GetRect().XMost() != aFrame->GetRect().x &&
|
|
|
|
aFrame->GetRect().XMost() != sibling->GetRect().x))
|
|
|
|
return nsnull;
|
|
|
|
return sibling;
|
|
|
|
}
|
2012-03-07 19:29:21 +04:00
|
|
|
|