Skip to content

Commit

Permalink
Revert "HTMLQuoteElement quote delimiters should be based on lang of …
Browse files Browse the repository at this point in the history
…parent"

This reverts commit a60add2.

Reason for revert: This CL is modifying the whole <q>'s lang but we only want it to modify the quote delimiters (q:before, q:after)

Original change's description:
> HTMLQuoteElement quote delimiters should be based on lang of parent
>
> Following the resolution of WHATWG HTML standard [1] and
> existing CSS issue [2], it has been decided that the
> auto (default) lang for <q> element should be based on the parent
> language, and not the language of the element itself.
>
> This CL makes sure to skip reading the lang attribute for <q>.
> Instead, its locale is calculated in
> CollectExtraStyleForPresentationAttribute(), using the parent's locale.
>
> [1] whatwg/html#3636
> [2] w3c/csswg-drafts#5478
>
> Change-Id: Ief17dd1e7f5a40112899ce898fa672a6fef6e834
> Fixed: 1290851
> Bug: 753671
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3704149
> Reviewed-by: Mason Freed <masonf@chromium.org>
> Commit-Queue: Di Zhang <dizhangg@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1016481}

Bug: 753671
Change-Id: I17d9a8fa3f0d1f2223f3e5b19595f701e7b5d6ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3717880
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1016912}
  • Loading branch information
dizhang168 authored and Chromium LUCI CQ committed Jun 22, 2022
1 parent 80840d8 commit 296cfd4
Show file tree
Hide file tree
Showing 8 changed files with 300 additions and 343 deletions.
1 change: 0 additions & 1 deletion third_party/blink/renderer/core/dom/element_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ class ElementData : public GarbageCollected<ElementData> {
private:
friend class Element;
friend class HTMLImageElement;
friend class HTMLQuoteElement;
friend class ShareableElementData;
friend class UniqueElementData;
friend class SVGElement;
Expand Down
7 changes: 0 additions & 7 deletions third_party/blink/renderer/core/html/html_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
#include "third_party/blink/renderer/core/html/html_dimension.h"
#include "third_party/blink/renderer/core/html/html_document.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/core/html/html_quote_element.h"
#include "third_party/blink/renderer/core/html/html_slot_element.h"
#include "third_party/blink/renderer/core/html/html_template_element.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
Expand Down Expand Up @@ -254,12 +253,6 @@ void HTMLElement::ApplyBorderAttributeToStyle(
void HTMLElement::MapLanguageAttributeToLocale(
const AtomicString& value,
MutableCSSPropertyValueSet* style) {
// HTMLQuoteElement should ignore own lang attribute and use lang of parent.
// This is handled in CollectExtraStyleForPresentationAttribute().
// https://github.com/w3c/csswg-drafts/issues/5478
if (IsA<HTMLQuoteElement>(this)) {
return;
}
if (!value.IsEmpty()) {
// Have to quote so the locale id is treated as a string instead of as a CSS
// keyword.
Expand Down
26 changes: 0 additions & 26 deletions third_party/blink/renderer/core/html/html_quote_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

#include "third_party/blink/renderer/core/html/html_quote_element.h"

#include "third_party/blink/renderer/core/css/css_markup.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/html_names.h"

Expand All @@ -34,7 +32,6 @@ HTMLQuoteElement::HTMLQuoteElement(const QualifiedName& tag_name,
: HTMLElement(tag_name, document) {
DCHECK(HasTagName(html_names::kQTag) ||
HasTagName(html_names::kBlockquoteTag));
SetHasCustomStyleCallbacks();
}

bool HTMLQuoteElement::IsURLAttribute(const Attribute& attribute) const {
Expand All @@ -51,27 +48,4 @@ const QualifiedName& HTMLQuoteElement::SubResourceAttributeName() const {
return html_names::kCiteAttr;
}

void HTMLQuoteElement::WillRecalcStyle(const StyleRecalcChange change) {
EnsureUniqueElementData().SetPresentationAttributeStyleIsDirty(true);
}

void HTMLQuoteElement::CollectExtraStyleForPresentationAttribute(
MutableCSSPropertyValueSet* style) {
HTMLElement::CollectExtraStyleForPresentationAttribute(style);

// <q> should ignore its own lang attribute and use lang of parent.
// https://github.com/w3c/csswg-drafts/issues/5478
Element* parent = parentElement();
if (parent) {
if (const AtomicString lang = parent->ComputeInheritedLanguage()) {
AddPropertyToPresentationAttributeStyle(
style, CSSPropertyID::kWebkitLocale, SerializeString(lang));
return;
}
}
// The empty string means the language is explicitly unknown.
AddPropertyToPresentationAttributeStyle(style, CSSPropertyID::kWebkitLocale,
CSSValueID::kAuto);
}

} // namespace blink
3 changes: 0 additions & 3 deletions third_party/blink/renderer/core/html/html_quote_element.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class HTMLQuoteElement final : public HTMLElement {
bool IsURLAttribute(const Attribute&) const override;
bool HasLegalLinkAttribute(const QualifiedName&) const override;
const QualifiedName& SubResourceAttributeName() const override;
void WillRecalcStyle(const StyleRecalcChange) override;
void CollectExtraStyleForPresentationAttribute(
MutableCSSPropertyValueSet*) override;
};

inline bool IsHTMLQuoteElement(const HTMLElement& element) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
body { font: 32px Arial, Helvetica, Noto Sans, DejaVu Sans, FreeSans, sans-serif; quotes: auto; }
</style>
<body>
<p>Test passes if the quote marks in each pair of lines match:
<p>Test passes if the quote marks in both lines match:
<p>One <q>two <q lang="ja">three <q lang="fr">four</q></q></q>
<p>One “two <span lang="ja">‘three <span lang="fr">『four』</span></span>

<p>One <q>two <q lang="ja">three <q>four</q></q></q>
<p>One “two <span lang="ja">‘three 『four』’</span>
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
body { font: 32px Arial, Helvetica, Noto Sans, DejaVu Sans, FreeSans, sans-serif; quotes: auto; }
</style>
<body>
<p>Test passes if the quote marks in each pair of lines match:
<p>Test passes if the quote marks in both lines match:
<p>One “two <span lang="ja">‘three <span lang="fr">『four』</span></span>
<p>One “two <span lang="ja">‘three <span lang="fr">『four』</span></span>

<p>One “two <span lang="ja">‘three 『four』’</span>
<p>One “two <span lang="ja">‘three 『four』’</span>

0 comments on commit 296cfd4

Please sign in to comment.