Files
palemoon27/dom/base/DirectionalityUtils.h
T
roytam1 fa6c289afc import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1148718 - init TextureSource for current TextureHost when attach. r=nical, r=sotaro (f1eb3995a)
- Bug 1022080 - Add surface dumping for X11 basic textures. r=nical (37e49a4ef)
- Bug 1022080 - Dump compositable textures as something that we can paste into the URL bar. r=nical (73a9f5756)
- Bug 1022080 - Split out the paint item dumping from the rest of the paint dumping. r=mattwoodrow (ee751065f)
- Bug 1103348 - Part 1: Correctly reset the direction of an ancestor that is still in the tree when a text node is removed; r=smontagu (20bb27d10)
- Bug 1103348 - Part 2: Test case; r=ehsan (b177d5e1e)
- Bug 1169267: treat an empty nsTextDirectionalityMap as missing when changing text content (fd61ffbce)
- Tests for bug 1169267 (3e316e9f5)
- Bug 1181443 (part 1) - Use nsTHashtable::Iterator in nsCheapSet. r=froydnj. (0375daaf7)
- Bug 1181443 (part 2) - Use nsTHashtable::Iterator in TestHashtables.cpp. r=froydnj. (65a6fd77c)
- Bug 1182962 (part 1) - Use nsTHashtable::Iterator in gfxUserFontSet. r=jfkthame. (c54843415)
- Bug 1182962 (part 2) - Use nsTHashtable::Iterator in gfxFont. r=jfkthame. (08323c06e)
- Bug 1182963 - Use nsTHashTable::Iterator in FramePropertyTable. r=njn (dc613f42a)
- Bug 1182958 - Use nsTHashTable::Iterator in image/. r=seth. (da247b700)
- Bug 1157086 - Fix order of test listing in dom/animation/test/mochitest.ini. r=birtles (abee03ed9)
- Bug 1157053 - Test restarting of finished transitions. r=birtles (6257c7854)
- Bug 1157074 - Fix Web Animations' Web Platform tests to make them use step_func when they should. r=birtles (a5ff7736b)
- Bug 1159743. Stop forcing the dom.animations-api.core.enabled preference on in the test harness. r=birtles (29a84181b)
- Bug 1166164 part 1 - Make setting the current time complete a pending pause, not abort it; r=jwatt (e952486dd)
- Bug 1166164 part 2 - Make UpdateFinishedState take a non-defaulted enum; r=jwatt (ad5a2db34)
- Bug 1166164 part 3 - Resolve start time on finish(); r=jwatt (1019f154d)
- Bug 1166164 part 4 - Make finished promise not resolve when paused; r=jwatt (f591576ed)
- Bug 1166164 part 5 - Make play() throw when it should seek to the end of an infinite effect; r=jwatt, r=smaug (0e18eb111)
- Bug 1134381 - Don't pause an AnimationPlayer if it is already paused; r=jwatt (0ae4d1f71)
- Bug 1166164 part 6 - Make pausing from idle set the current time; r=jwatt, r=smaug (bd97211ef)
- Bug 1166164 part 7 - Call pause directly when creating an initially-paused animation; r=jwatt (eefeca3fe)
- Bug 1166164 part 8 - Drop a few references to players; r=jwatt (e89f33188)
- Bug 1147940 - Remove the dom.webcrypto.enabled pref as it is no longer necessary. r=smaug,r=rbarnes (4a329477f)
- Bug 1178186 part 1 - Add CSSAnimation and CSSTransition interfaces; r=smaug (64b61a9d2)
- Bug 1178186 part 2 - Add tests for CSSAnimation and CSSTransition interfaces; r=jwatt (9157d7172)
- Bug 1159117 - Test emulation of formats removed in core profiles. r=jgilbert (9cbcbb325)
2021-03-22 09:16:23 +08:00

147 lines
5.2 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef DirectionalityUtils_h___
#define DirectionalityUtils_h___
#include "nscore.h"
class nsIContent;
class nsAString;
class nsAttrValue;
class nsTextNode;
namespace mozilla {
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
namespace mozilla {
enum Directionality {
eDir_NotSet,
eDir_RTL,
eDir_LTR,
eDir_Auto
};
/**
* Set the directionality of an element according to the algorithm defined at
* http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#the-directionality,
* not including elements with auto direction.
*
* @return the directionality that the element was set to
*/
Directionality RecomputeDirectionality(mozilla::dom::Element* aElement,
bool aNotify = true);
/**
* Set the directionality of any descendants of a node that do not themselves
* have a dir attribute.
* For performance reasons we walk down the descendant tree in the rare case
* of setting the dir attribute, rather than walking up the ancestor tree in
* the much more common case of getting the element's directionality.
*/
void SetDirectionalityOnDescendants(mozilla::dom::Element* aElement,
Directionality aDir,
bool aNotify = true);
/**
* Walk the descendants of a node in tree order and, for any text node
* descendant that determines the directionality of some element and is not a
* descendant of another descendant of the original node with dir=auto,
* redetermine that element's directionality
*/
void WalkDescendantsResetAutoDirection(mozilla::dom::Element* aElement);
/**
* After setting dir=auto on an element, walk its descendants in tree order.
* If the node doesn't have the NODE_ANCESTOR_HAS_DIR_AUTO flag, set the
* NODE_ANCESTOR_HAS_DIR_AUTO flag on all of its descendants.
* Resolve the directionality of the element by the "downward propagation
* algorithm" (defined in section 3 in the comments at the beginning of
* DirectionalityUtils.cpp)
*/
void WalkDescendantsSetDirAuto(mozilla::dom::Element* aElement,
bool aNotify = true);
/**
* After unsetting dir=auto on an element, walk its descendants in tree order,
* skipping any that have dir=auto themselves, and unset the
* NODE_ANCESTOR_HAS_DIR_AUTO flag
*/
void WalkDescendantsClearAncestorDirAuto(mozilla::dom::Element* aElement);
/**
* When the contents of a text node are about to change, retrieve the current
* directionality of the text
*
* @return whether the text node affects the directionality of any element
*/
bool TextNodeWillChangeDirection(nsIContent* aTextNode, Directionality* aOldDir,
uint32_t aOffset);
/**
* After the contents of a text node have changed, change the directionality
* of any elements whose directionality is determined by that node
*/
void TextNodeChangedDirection(nsIContent* aTextNode, Directionality aOldDir,
bool aNotify);
/**
* When a text node is appended to an element, find any ancestors with dir=auto
* whose directionality will be determined by the text node
*/
void SetDirectionFromNewTextNode(nsIContent* aTextNode);
/**
* When a text node is removed from a document, find any ancestors whose
* directionality it determined and redetermine their directionality
*
* @param aTextNode the text node
*/
void ResetDirectionSetByTextNode(nsTextNode* aTextNode);
/**
* Set the directionality of an element according to the directionality of the
* text in aValue
*/
void SetDirectionalityFromValue(mozilla::dom::Element* aElement,
const nsAString& aValue,
bool aNotify);
/**
* Called when setting the dir attribute on an element, immediately after
* AfterSetAttr. This is instead of using BeforeSetAttr or AfterSetAttr, because
* in AfterSetAttr we don't know the old value, so we can't identify all cases
* where we need to walk up or down the document tree and reset the direction;
* and in BeforeSetAttr we can't do the walk because this element hasn't had the
* value set yet so the results will be wrong.
*/
void OnSetDirAttr(mozilla::dom::Element* aElement,
const nsAttrValue* aNewValue,
bool hadValidDir,
bool hadDirAuto,
bool aNotify);
/**
* Called when binding a new element to the tree, to set the
* NodeAncestorHasDirAuto flag and set the direction of the element and its
* ancestors if necessary
*/
void SetDirOnBind(mozilla::dom::Element* aElement, nsIContent* aParent);
/**
* Called when unbinding an element from the tree, to recompute the
* directionality of the element if it doesn't have autodirection, and to
* clean up any entries in nsTextDirectionalityMap that refer to it.
*/
void ResetDir(mozilla::dom::Element* aElement);
} // end namespace mozilla
#endif /* DirectionalityUtils_h___ */