Diff
Modified: trunk/LayoutTests/ChangeLog (111631 => 111632)
--- trunk/LayoutTests/ChangeLog 2012-03-22 00:58:36 UTC (rev 111631)
+++ trunk/LayoutTests/ChangeLog 2012-03-22 01:08:22 UTC (rev 111632)
@@ -1,3 +1,15 @@
+2012-03-21 Ryosuke Niwa <[email protected]>
+
+ BDI element should have dir=auto by default
+ https://bugs.webkit.org/show_bug.cgi?id=68773
+
+ Reviewed by Daniel Bates.
+
+ Add a test written by Aharon Lanin.
+
+ * fast/text/international/bdi-dir-default-to-auto-expected.html: Added.
+ * fast/text/international/bdi-dir-default-to-auto.html: Added.
+
2012-03-21 Eric Carlson <[email protected]>
http/tests/media/video-useragent.html should be skipped on Mac
Added: trunk/LayoutTests/fast/text/international/bdi-dir-default-to-auto-expected.html (0 => 111632)
--- trunk/LayoutTests/fast/text/international/bdi-dir-default-to-auto-expected.html (rev 0)
+++ trunk/LayoutTests/fast/text/international/bdi-dir-default-to-auto-expected.html 2012-03-22 01:08:22 UTC (rev 111632)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <link rel="author" title="Aharon Lanin" href=""
+ <link rel="author" title="HTML5 bidi test WG" href=""
+ <style>
+ body{
+ font-size:2em;
+ }
+ .box {
+ border: medium solid gray;
+ width: 500px;
+ margin: 20px;
+ }
+ </style>
+ </head>
+ <body>
+ The two boxes below should look exactly the same.
+ <!-- Key to entities used below:
+ א ... ו - The first six Hebrew letters (strongly RTL).
+ ‭ - The LRO (left-to-right-override) formatting character.
+ ‬ - The PDF (pop directional formatting) formatting character; closes LRO. -->
+ <div class="box">
+ <div dir="ltr">‭[:)], [+- a ב], [d ג 1]...‬</div>
+ <div dir="rtl">‭...[d ג 1] ,[+- a ב] ,[:)]‬</div>
+ </div>
+ <div class="box">
+ <div dir="ltr">‭[:)], [+- a ב], [d ג 1]...‬</div>
+ <div dir="rtl">‭...[d ג 1] ,[+- a ב] ,[:)]‬</div>
+ </div>
+ </body>
+</html>
Added: trunk/LayoutTests/fast/text/international/bdi-dir-default-to-auto.html (0 => 111632)
--- trunk/LayoutTests/fast/text/international/bdi-dir-default-to-auto.html (rev 0)
+++ trunk/LayoutTests/fast/text/international/bdi-dir-default-to-auto.html 2012-03-22 01:08:22 UTC (rev 111632)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>HTML Test: BDI: paragraph-level container</title>
+ <link rel="reference" href=""
+ <link rel="author" title="Aharon Lanin" href=""
+ <link rel="author" title="HTML5 bidi test WG" href=""
+ <link rel="help" href=""
+ <meta name="assert" content="
+ 'The dir global attribute defaults to auto on this element (it never inherits from the parent
+ element like with other elements).'">
+ <style>
+ body{
+ font-size:2em;
+ }
+ .box {
+ border: medium solid gray;
+ width: 500px;
+ margin: 20px;
+ }
+ </style>
+ </head>
+ <body>
+ The two boxes below should look exactly the same.
+ <!-- Key to entities used below:
+ א ... ו - The first six Hebrew letters (strongly RTL).
+ ‭ - The LRO (left-to-right-override) formatting character.
+ ‬ - The PDF (pop directional formatting) formatting character; closes LRO. -->
+ <div class="box">
+ <!--
+ In each DIV below:
+ - the first BDI, having no characters with strong direction, should be LTR by default;
+ - the second BDI, having an LTR character first, should be LTR by default;
+ - the third BDI, having an RTL character first, should be RTL by default.
+ -->
+ <div dir="ltr"><bdi>[:)]</bdi>, <bdi>[+- a ב]</bdi>, <bdi>[1 ג d]</bdi>...</div>
+ <div dir="rtl"><bdi>[:)]</bdi>, <bdi>[+- a ב]</bdi>, <bdi>[1 ג d]</bdi>...</div>
+ </div>
+ <div class="box">
+ <div dir="ltr">‭[:)], [+- a ב], [d ג 1]...‬</div>
+ <div dir="rtl">‭...[d ג 1] ,[+- a ב] ,[:)]‬</div>
+ </div>
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (111631 => 111632)
--- trunk/Source/WebCore/ChangeLog 2012-03-22 00:58:36 UTC (rev 111631)
+++ trunk/Source/WebCore/ChangeLog 2012-03-22 01:08:22 UTC (rev 111632)
@@ -1,3 +1,51 @@
+2012-03-21 Ryosuke Niwa <[email protected]>
+
+ BDI element should have dir=auto by default
+ https://bugs.webkit.org/show_bug.cgi?id=68773
+
+ Reviewed by Daniel Bates.
+
+ Treat bdi elements without dir content attribute as if they have dir=auto per spec:
+ http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-bdi-element
+
+ The patch tries to encapsulate the logic to look for dir content attribute and dir=auto.
+
+ It also adds HTMLBDIElement interface (binding remains to use HTMLElement) to set
+ selfOrAncestorHasDirAutoAttribute flag true by default, which is used by functions like
+ directionalityIfhasDirAutoAttribute to look for elements with dir=auto. Since dir=auto-ness of bdi
+ elements can be overridden by dir content attribute, we must change and only change the default value.
+
+ Tests: fast/text/international/bdi-dir-default-to-auto-expected.html
+ fast/text/international/bdi-dir-default-to-auto.html
+
+ * GNUmakefile.list.am:
+ * Target.pri:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/CSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::collectMatchingRulesForList):
+ * html/HTMLBDIElement.h: Added.
+ (WebCore):
+ (HTMLBDIElement):
+ (WebCore::HTMLBDIElement::create):
+ (WebCore::HTMLBDIElement::HTMLBDIElement): Sets selfOrAncestorHasDirAutoAttribute to true because
+ bdi elements are treated as if it has dir=auto by default.
+ * html/HTMLElement.cpp:
+ (WebCore::elementAffectsDirectionality): Added. Checks if the specified element is bdi or
+ has dir content attribute.
+ (WebCore):
+ (WebCore::setHasDirAutoFlagRecursively):
+ (WebCore::HTMLElement::hasDirectionAuto): Added. Checks if the specified element should be treated
+ as if it has dir=auto (bdi or element with dir=auto).
+ (WebCore::HTMLElement::directionalityIfhasDirAutoAttribute):
+ (WebCore::HTMLElement::adjustDirectionalityIfNeededAfterChildAttributeChanged):
+ (WebCore::HTMLElement::adjustDirectionalityIfNeededAfterChildrenChanged):
+ * html/HTMLElement.h:
+ (HTMLElement):
+ * html/HTMLTagNames.in: Use HTMLBDIElement instead of HTMLElement for constructing bdi element
+ to set selfOrAncestorHasDirAutoAttribute true but still use HTMLElement for binding.
+
2012-03-21 Luke Macpherson <[email protected]>
Use CSSPrimitiveValue::convertToLength() in a few places.
Modified: trunk/Source/WebCore/GNUmakefile.list.am (111631 => 111632)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-03-22 00:58:36 UTC (rev 111631)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-03-22 01:08:22 UTC (rev 111632)
@@ -2216,6 +2216,7 @@
Source/WebCore/html/HTMLBaseElement.h \
Source/WebCore/html/HTMLBaseFontElement.cpp \
Source/WebCore/html/HTMLBaseFontElement.h \
+ Source/WebCore/html/HTMLBDIElement.h \
Source/WebCore/html/HTMLBodyElement.cpp \
Source/WebCore/html/HTMLBodyElement.h \
Source/WebCore/html/HTMLBRElement.cpp \
Modified: trunk/Source/WebCore/Target.pri (111631 => 111632)
--- trunk/Source/WebCore/Target.pri 2012-03-22 00:58:36 UTC (rev 111631)
+++ trunk/Source/WebCore/Target.pri 2012-03-22 01:08:22 UTC (rev 111632)
@@ -1848,6 +1848,7 @@
html/HTMLBaseElement.h \
html/HTMLBaseFontElement.h \
html/HTMLBodyElement.h \
+ html/HTMLBDIElement.h \
html/HTMLBRElement.h \
html/HTMLButtonElement.h \
html/HTMLCanvasElement.h \
Modified: trunk/Source/WebCore/WebCore.gypi (111631 => 111632)
--- trunk/Source/WebCore/WebCore.gypi 2012-03-22 00:58:36 UTC (rev 111631)
+++ trunk/Source/WebCore/WebCore.gypi 2012-03-22 01:08:22 UTC (rev 111632)
@@ -5327,6 +5327,7 @@
'html/HTMLAreaElement.h',
'html/HTMLAudioElement.cpp',
'html/HTMLAudioElement.h',
+ 'html/HTMLBDIElement.h',
'html/HTMLBRElement.cpp',
'html/HTMLBRElement.h',
'html/HTMLBaseElement.cpp',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (111631 => 111632)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-03-22 00:58:36 UTC (rev 111631)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-03-22 01:08:22 UTC (rev 111632)
@@ -57674,6 +57674,10 @@
>
</File>
<File
+ RelativePath="..\html\HTMLBDIElement.h"
+ >
+ </File>
+ <File
RelativePath="..\html\HTMLBodyElement.cpp"
>
<FileConfiguration
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (111631 => 111632)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-03-22 00:58:36 UTC (rev 111631)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-03-22 01:08:22 UTC (rev 111632)
@@ -3585,6 +3585,7 @@
98EB1F951313FE0500D0E1EA /* NotImplemented.h in Headers */ = {isa = PBXBuildFile; fileRef = 98EB1F941313FE0500D0E1EA /* NotImplemented.h */; settings = {ATTRIBUTES = (Private, ); }; };
9B0FB191140DB5790022588F /* HTTPValidation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B0FB18F140DB5790022588F /* HTTPValidation.cpp */; };
9B0FB192140DB5790022588F /* HTTPValidation.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B0FB190140DB5790022588F /* HTTPValidation.h */; };
+ 9B24DE8E15194B9500C59C27 /* HTMLBDIElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B24DE8C15194B9500C59C27 /* HTMLBDIElement.h */; };
9B2B7AC11509850A008932CC /* MicroDataItemValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B2F7CF714562120007F8B50 /* MicroDataItemValue.cpp */; };
9B2D8A7914997CCF00ECEF3E /* UndoStep.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B2D8A7814997CCF00ECEF3E /* UndoStep.h */; settings = {ATTRIBUTES = (Private, ); }; };
9B32CDA913DF7FA900F34D13 /* RenderedPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B32CDA713DF7FA900F34D13 /* RenderedPosition.h */; };
@@ -10561,6 +10562,7 @@
98EB1F941313FE0500D0E1EA /* NotImplemented.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotImplemented.h; sourceTree = "<group>"; };
9B0FB18F140DB5790022588F /* HTTPValidation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPValidation.cpp; sourceTree = "<group>"; };
9B0FB190140DB5790022588F /* HTTPValidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPValidation.h; sourceTree = "<group>"; };
+ 9B24DE8C15194B9500C59C27 /* HTMLBDIElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLBDIElement.h; sourceTree = "<group>"; };
9B2D8A7814997CCF00ECEF3E /* UndoStep.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UndoStep.h; sourceTree = "<group>"; };
9B2F7CF714562120007F8B50 /* MicroDataItemValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MicroDataItemValue.cpp; sourceTree = "<group>"; };
9B2F7CF814562120007F8B50 /* MicroDataItemValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MicroDataItemValue.h; sourceTree = "<group>"; };
@@ -13642,7 +13644,7 @@
1AE82EC90CAAE177002237AE /* storage */,
B22277CA0D00BF1E0071B782 /* svg */,
417DA4CD13734204007C57FB /* testing */,
- FD315FA212B025B100C1A359 /* webaudio */,
+ FD315FA212B025B100C1A359 /* Modules/webaudio */,
2E4346310F546A6800B0F1BA /* workers */,
E1F0424309839389006694EA /* xml */,
656580EC09D12B20000E61D7 /* Derived Sources */,
@@ -16771,6 +16773,7 @@
A8DF3FCB097FA0FB0052981B /* HTMLBaseFontElement.cpp */,
A8DF3FCA097FA0FB0052981B /* HTMLBaseFontElement.h */,
1AE2A9F10A1CDA5700B42B25 /* HTMLBaseFontElement.idl */,
+ 9B24DE8C15194B9500C59C27 /* HTMLBDIElement.h */,
A871DE1D0A152AC800B12A68 /* HTMLBodyElement.cpp */,
A871DE200A152AC800B12A68 /* HTMLBodyElement.h */,
1AE2A9F20A1CDA5700B42B25 /* HTMLBodyElement.idl */,
@@ -21169,7 +21172,7 @@
path = opengl;
sourceTree = "<group>";
};
- FD315FA212B025B100C1A359 /* webaudio */ = {
+ FD315FA212B025B100C1A359 /* Modules/webaudio */ = {
isa = PBXGroup;
children = (
FD5686C713AC180200B69C68 /* AsyncAudioDecoder.cpp */,
@@ -22690,6 +22693,7 @@
E44613A20CD6331000FADA75 /* HTMLAudioElement.h in Headers */,
A871DC1F0A15205700B12A68 /* HTMLBaseElement.h in Headers */,
A8DF3FD2097FA0FC0052981B /* HTMLBaseFontElement.h in Headers */,
+ 9B24DE8E15194B9500C59C27 /* HTMLBDIElement.h in Headers */,
A871DE2C0A152AC800B12A68 /* HTMLBodyElement.h in Headers */,
A8CFF7AA0A156978000A4234 /* HTMLBRElement.h in Headers */,
A81369D2097374F600D74463 /* HTMLButtonElement.h in Headers */,
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (111631 => 111632)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2012-03-22 00:58:36 UTC (rev 111631)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2012-03-22 01:08:22 UTC (rev 111632)
@@ -1273,6 +1273,11 @@
return true;
}
+inline bool elementHasDirectionAuto(Element* element)
+{
+ return element->isHTMLElement() && toHTMLElement(element)->hasDirectionAuto();
+}
+
bool CSSStyleSelector::canShareStyleWithElement(StyledElement* element) const
{
RenderStyle* style = element->renderStyle();
@@ -1367,7 +1372,7 @@
return false;
#endif
- if (equalIgnoringCase(element->fastGetAttribute(dirAttr), "auto") || equalIgnoringCase(m_element->fastGetAttribute(dirAttr), "auto"))
+ if (elementHasDirectionAuto(element) || elementHasDirectionAuto(m_element))
return false;
if (element->hasClass() && m_element->getAttribute(classAttr) != element->getAttribute(classAttr))
Added: trunk/Source/WebCore/html/HTMLBDIElement.h (0 => 111632)
--- trunk/Source/WebCore/html/HTMLBDIElement.h (rev 0)
+++ trunk/Source/WebCore/html/HTMLBDIElement.h 2012-03-22 01:08:22 UTC (rev 111632)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef HTMLBDIElement_h
+#define HTMLBDIElement_h
+
+#include "HTMLElement.h"
+
+namespace WebCore {
+
+class HTMLBDIElement : public HTMLElement {
+public:
+ static PassRefPtr<HTMLBDIElement> create(const QualifiedName& name, Document* document)
+ {
+ return adoptRef(new HTMLBDIElement(name, document));
+ }
+
+private:
+ HTMLBDIElement(const QualifiedName& name, Document* document)
+ : HTMLElement(name, document)
+ {
+ // FIXME: Rename setSelfOrAncestorHasDirAutoAttribute to reflect the fact bdi also uses this flag.
+ setSelfOrAncestorHasDirAutoAttribute(true);
+ }
+};
+
+} // namespace WebCore
+
+#endif
Modified: trunk/Source/WebCore/html/HTMLElement.cpp (111631 => 111632)
--- trunk/Source/WebCore/html/HTMLElement.cpp 2012-03-22 00:58:36 UTC (rev 111631)
+++ trunk/Source/WebCore/html/HTMLElement.cpp 2012-03-22 01:08:22 UTC (rev 111632)
@@ -795,6 +795,11 @@
return findFormAncestor();
}
+static inline bool elementAffectsDirectionality(const Node* node)
+{
+ return node->isHTMLElement() && (node->hasTagName(bdiTag) || toHTMLElement(node)->hasAttribute(dirAttr));
+}
+
static void setHasDirAutoFlagRecursively(Node* firstNode, bool flag, Node* lastNode = 0)
{
firstNode->setSelfOrAncestorHasDirAutoAttribute(flag);
@@ -805,7 +810,7 @@
if (node->selfOrAncestorHasDirAutoAttribute() == flag)
return;
- if (node->isHTMLElement() && toElement(node)->hasAttribute(dirAttr)) {
+ if (elementAffectsDirectionality(node)) {
if (node == lastNode)
return;
node = node->traverseNextSibling(firstNode);
@@ -824,9 +829,15 @@
adjustDirectionalityIfNeededAfterChildrenChanged(beforeChange, childCountDelta);
}
+bool HTMLElement::hasDirectionAuto() const
+{
+ const AtomicString& direction = fastGetAttribute(dirAttr);
+ return (hasTagName(bdiTag) && direction == nullAtom) || equalIgnoringCase(direction, "auto");
+}
+
TextDirection HTMLElement::directionalityIfhasDirAutoAttribute(bool& isAuto) const
{
- if (!(selfOrAncestorHasDirAutoAttribute() && equalIgnoringCase(getAttribute(dirAttr), "auto"))) {
+ if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) {
isAuto = false;
return LTR;
}
@@ -899,7 +910,7 @@
if (renderer() && renderer()->style() && renderer()->style()->direction() != textDirection) {
Element* elementToAdjust = this;
for (; elementToAdjust; elementToAdjust = elementToAdjust->parentElement()) {
- if (elementToAdjust->hasAttribute(dirAttr)) {
+ if (elementAffectsDirectionality(elementToAdjust)) {
elementToAdjust->setNeedsStyleRecalc();
return;
}
@@ -921,7 +932,7 @@
if ((!document() || document()->renderer()) && childCountDelta < 0) {
Node* node = beforeChange ? beforeChange->traverseNextSibling() : 0;
for (int counter = 0; node && counter < childCountDelta; counter++, node = node->traverseNextSibling()) {
- if (node->isElementNode() && toElement(node)->hasAttribute(dirAttr))
+ if (elementAffectsDirectionality(node))
continue;
setHasDirAutoFlagRecursively(node, false);
@@ -932,13 +943,13 @@
return;
Node* oldMarkedNode = beforeChange ? beforeChange->traverseNextSibling() : 0;
- while (oldMarkedNode && oldMarkedNode->isHTMLElement() && toHTMLElement(oldMarkedNode)->hasAttribute(dirAttr))
+ while (oldMarkedNode && elementAffectsDirectionality(oldMarkedNode))
oldMarkedNode = oldMarkedNode->traverseNextSibling(this);
if (oldMarkedNode)
setHasDirAutoFlagRecursively(oldMarkedNode, false);
for (Element* elementToAdjust = this; elementToAdjust; elementToAdjust = elementToAdjust->parentElement()) {
- if (elementToAdjust->isHTMLElement() && elementToAdjust->hasAttribute(dirAttr)) {
+ if (elementAffectsDirectionality(elementToAdjust)) {
toHTMLElement(elementToAdjust)->calculateAndAdjustDirectionality();
return;
}
Modified: trunk/Source/WebCore/html/HTMLElement.h (111631 => 111632)
--- trunk/Source/WebCore/html/HTMLElement.h 2012-03-22 00:58:36 UTC (rev 111631)
+++ trunk/Source/WebCore/html/HTMLElement.h 2012-03-22 01:08:22 UTC (rev 111632)
@@ -90,6 +90,7 @@
HTMLFormElement* findFormAncestor() const;
+ bool hasDirectionAuto() const;
TextDirection directionalityIfhasDirAutoAttribute(bool& isAuto) const;
#if ENABLE(MICRODATA)
Modified: trunk/Source/WebCore/html/HTMLTagNames.in (111631 => 111632)
--- trunk/Source/WebCore/html/HTMLTagNames.in 2012-03-22 00:58:36 UTC (rev 111631)
+++ trunk/Source/WebCore/html/HTMLTagNames.in 2012-03-22 01:08:22 UTC (rev 111632)
@@ -15,7 +15,7 @@
b interfaceName=HTMLElement
base
basefont interfaceName=HTMLBaseFontElement
-bdi interfaceName=HTMLElement
+bdi interfaceName=HTMLBDIElement, JSInterfaceName=HTMLElement
bdo interfaceName=HTMLElement
bgsound interfaceName=HTMLElement
big interfaceName=HTMLElement