gecko-dev/layout/style/nsHTMLStyleSheet.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

85 строки
2.7 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
2012-05-21 15:12:37 +04:00
* 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/. */
/*
* style sheet and style rule processor representing data from presentational
* HTML attributes
*/
#ifndef nsHTMLStyleSheet_h_
#define nsHTMLStyleSheet_h_
#include "nsColor.h"
#include "nsCOMPtr.h"
#include "nsAtom.h"
#include "PLDHashTable.h"
#include "mozilla/Attributes.h"
#include "mozilla/MemoryReporting.h"
Bug 234485: Map xml:lang attribute into style so that it's used for font selection and hyphenation. r=bzbarsky The code in nsHTMLStyleSheet implements LangRule to map xml:lang into style and the code to manage its uniqueness. The change to nsGenericHTMLElement fixes the mapping of the HTML lang attribute to do cascading the way all other rule mapping does so that the cascading works correctly. The tests test that the correct style language is used for hyphenation by copying over a set of hyphenation reftests that check its basic response to languages. There are no specific tests for font selection, but font selection is known to use the same language data from style. I verified manually (see other attachments to bug) that the rule uniqueness is being managed correctly. --HG-- rename : layout/reftests/text/auto-hyphenation-1.html => layout/reftests/text/auto-hyphenation-xmllang-1.xhtml rename : layout/reftests/text/auto-hyphenation-10.html => layout/reftests/text/auto-hyphenation-xmllang-10.xhtml rename : layout/reftests/text/auto-hyphenation-1.html => layout/reftests/text/auto-hyphenation-xmllang-11a.xhtml rename : layout/reftests/text/auto-hyphenation-1.html => layout/reftests/text/auto-hyphenation-xmllang-11b.xhtml rename : layout/reftests/text/auto-hyphenation-4.html => layout/reftests/text/auto-hyphenation-xmllang-12a.xhtml rename : layout/reftests/text/auto-hyphenation-4.html => layout/reftests/text/auto-hyphenation-xmllang-12b.xhtml rename : layout/reftests/text/auto-hyphenation-1.html => layout/reftests/text/auto-hyphenation-xmllang-13a.xhtml rename : layout/reftests/text/auto-hyphenation-1.html => layout/reftests/text/auto-hyphenation-xmllang-13b.xhtml rename : layout/reftests/text/auto-hyphenation-4.html => layout/reftests/text/auto-hyphenation-xmllang-14a.xhtml rename : layout/reftests/text/auto-hyphenation-4.html => layout/reftests/text/auto-hyphenation-xmllang-14b.xhtml rename : layout/reftests/text/auto-hyphenation-1a.html => layout/reftests/text/auto-hyphenation-xmllang-1a.xhtml rename : layout/reftests/text/auto-hyphenation-2.html => layout/reftests/text/auto-hyphenation-xmllang-2.xhtml rename : layout/reftests/text/auto-hyphenation-3.html => layout/reftests/text/auto-hyphenation-xmllang-3.xhtml rename : layout/reftests/text/auto-hyphenation-4.html => layout/reftests/text/auto-hyphenation-xmllang-4.xhtml rename : layout/reftests/text/auto-hyphenation-5.html => layout/reftests/text/auto-hyphenation-xmllang-5.xhtml rename : layout/reftests/text/auto-hyphenation-6.html => layout/reftests/text/auto-hyphenation-xmllang-6.xhtml rename : layout/reftests/text/auto-hyphenation-7.html => layout/reftests/text/auto-hyphenation-xmllang-7.xhtml rename : layout/reftests/text/auto-hyphenation-8.html => layout/reftests/text/auto-hyphenation-xmllang-8.xhtml rename : layout/reftests/text/auto-hyphenation-9.html => layout/reftests/text/auto-hyphenation-xmllang-9.xhtml
2013-05-30 12:00:20 +04:00
#include "nsString.h"
class nsMappedAttributes;
struct RawServoDeclarationBlock;
class nsHTMLStyleSheet final {
public:
explicit nsHTMLStyleSheet(mozilla::dom::Document* aDocument);
void SetOwningDocument(mozilla::dom::Document* aDocument);
NS_INLINE_DECL_REFCOUNTING(nsHTMLStyleSheet)
size_t DOMSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
void Reset();
nsresult SetLinkColor(nscolor aColor);
nsresult SetActiveLinkColor(nscolor aColor);
nsresult SetVisitedLinkColor(nscolor aColor);
const RefPtr<RawServoDeclarationBlock>& GetServoUnvisitedLinkDecl() const {
return mServoUnvisitedLinkDecl;
}
const RefPtr<RawServoDeclarationBlock>& GetServoVisitedLinkDecl() const {
return mServoVisitedLinkDecl;
}
const RefPtr<RawServoDeclarationBlock>& GetServoActiveLinkDecl() const {
return mServoActiveLinkDecl;
}
// Mapped Attribute management methods
already_AddRefed<nsMappedAttributes> UniqueMappedAttributes(
nsMappedAttributes* aMapped);
void DropMappedAttributes(nsMappedAttributes* aMapped);
// For each mapped presentation attribute in the cache, resolve
// the attached DeclarationBlock by running the mapping
// and converting the ruledata to Servo specified values.
void CalculateMappedServoDeclarations();
private:
nsHTMLStyleSheet(const nsHTMLStyleSheet& aCopy) = delete;
nsHTMLStyleSheet& operator=(const nsHTMLStyleSheet& aCopy) = delete;
~nsHTMLStyleSheet() {}
// Implementation of SetLink/VisitedLink/ActiveLinkColor
nsresult ImplLinkColorSetter(RefPtr<RawServoDeclarationBlock>& aDecl,
nscolor aColor);
Bug 234485: Map xml:lang attribute into style so that it's used for font selection and hyphenation. r=bzbarsky The code in nsHTMLStyleSheet implements LangRule to map xml:lang into style and the code to manage its uniqueness. The change to nsGenericHTMLElement fixes the mapping of the HTML lang attribute to do cascading the way all other rule mapping does so that the cascading works correctly. The tests test that the correct style language is used for hyphenation by copying over a set of hyphenation reftests that check its basic response to languages. There are no specific tests for font selection, but font selection is known to use the same language data from style. I verified manually (see other attachments to bug) that the rule uniqueness is being managed correctly. --HG-- rename : layout/reftests/text/auto-hyphenation-1.html => layout/reftests/text/auto-hyphenation-xmllang-1.xhtml rename : layout/reftests/text/auto-hyphenation-10.html => layout/reftests/text/auto-hyphenation-xmllang-10.xhtml rename : layout/reftests/text/auto-hyphenation-1.html => layout/reftests/text/auto-hyphenation-xmllang-11a.xhtml rename : layout/reftests/text/auto-hyphenation-1.html => layout/reftests/text/auto-hyphenation-xmllang-11b.xhtml rename : layout/reftests/text/auto-hyphenation-4.html => layout/reftests/text/auto-hyphenation-xmllang-12a.xhtml rename : layout/reftests/text/auto-hyphenation-4.html => layout/reftests/text/auto-hyphenation-xmllang-12b.xhtml rename : layout/reftests/text/auto-hyphenation-1.html => layout/reftests/text/auto-hyphenation-xmllang-13a.xhtml rename : layout/reftests/text/auto-hyphenation-1.html => layout/reftests/text/auto-hyphenation-xmllang-13b.xhtml rename : layout/reftests/text/auto-hyphenation-4.html => layout/reftests/text/auto-hyphenation-xmllang-14a.xhtml rename : layout/reftests/text/auto-hyphenation-4.html => layout/reftests/text/auto-hyphenation-xmllang-14b.xhtml rename : layout/reftests/text/auto-hyphenation-1a.html => layout/reftests/text/auto-hyphenation-xmllang-1a.xhtml rename : layout/reftests/text/auto-hyphenation-2.html => layout/reftests/text/auto-hyphenation-xmllang-2.xhtml rename : layout/reftests/text/auto-hyphenation-3.html => layout/reftests/text/auto-hyphenation-xmllang-3.xhtml rename : layout/reftests/text/auto-hyphenation-4.html => layout/reftests/text/auto-hyphenation-xmllang-4.xhtml rename : layout/reftests/text/auto-hyphenation-5.html => layout/reftests/text/auto-hyphenation-xmllang-5.xhtml rename : layout/reftests/text/auto-hyphenation-6.html => layout/reftests/text/auto-hyphenation-xmllang-6.xhtml rename : layout/reftests/text/auto-hyphenation-7.html => layout/reftests/text/auto-hyphenation-xmllang-7.xhtml rename : layout/reftests/text/auto-hyphenation-8.html => layout/reftests/text/auto-hyphenation-xmllang-8.xhtml rename : layout/reftests/text/auto-hyphenation-9.html => layout/reftests/text/auto-hyphenation-xmllang-9.xhtml
2013-05-30 12:00:20 +04:00
public: // for mLangRuleTable structures only
private:
mozilla::dom::Document* mDocument;
RefPtr<RawServoDeclarationBlock> mServoUnvisitedLinkDecl;
RefPtr<RawServoDeclarationBlock> mServoVisitedLinkDecl;
RefPtr<RawServoDeclarationBlock> mServoActiveLinkDecl;
PLDHashTable mMappedAttrTable;
// Whether or not the mapped attributes table
// has been changed since the last call to
// CalculateMappedServoDeclarations()
bool mMappedAttrsDirty;
};
#endif /* !defined(nsHTMLStyleSheet_h_) */