[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
rniwa at webkit.org
rniwa at webkit.org
Wed Dec 22 11:51:05 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit ec186f401438457cd322f5e9d2da7b92e1dcb38f
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Aug 9 23:18:37 2010 +0000
2010-08-09 Ryosuke Niwa <rniwa at webkit.org>
Reviewed by Tony Chang.
Use getIdentifierValue to obtain direction and unicode-bidi properties in ApplyStyleCommand
https://bugs.webkit.org/show_bug.cgi?id=43699
Deployed getIdentifierValue in various parts of ApplyStyleCommand where
direction and unicode-bidi properties were obtained manually.
No new tests since this is a cleanup.
* editing/ApplyStyleCommand.cpp:
(WebCore::getIdentifierValue): Takes CSSStyleDeclaration instead of CSSMutableStyleDeclaration.
(WebCore::ApplyStyleCommand::splitAncestorsWithUnicodeBidi): Calls getIdentifierValue.
(WebCore::ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock): Calls getIdentifierValue.
(WebCore::ApplyStyleCommand::applyInlineStyle): Calls getIdentifierValue.
* editing/ApplyStyleCommand.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3823c07..362ba21 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-08-09 Ryosuke Niwa <rniwa at webkit.org>
+
+ Reviewed by Tony Chang.
+
+ Use getIdentifierValue to obtain direction and unicode-bidi properties in ApplyStyleCommand
+ https://bugs.webkit.org/show_bug.cgi?id=43699
+
+ Deployed getIdentifierValue in various parts of ApplyStyleCommand where
+ direction and unicode-bidi properties were obtained manually.
+
+ No new tests since this is a cleanup.
+
+ * editing/ApplyStyleCommand.cpp:
+ (WebCore::getIdentifierValue): Takes CSSStyleDeclaration instead of CSSMutableStyleDeclaration.
+ (WebCore::ApplyStyleCommand::splitAncestorsWithUnicodeBidi): Calls getIdentifierValue.
+ (WebCore::ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock): Calls getIdentifierValue.
+ (WebCore::ApplyStyleCommand::applyInlineStyle): Calls getIdentifierValue.
+ * editing/ApplyStyleCommand.h:
+
2010-08-09 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
diff --git a/WebCore/editing/ApplyStyleCommand.cpp b/WebCore/editing/ApplyStyleCommand.cpp
index 6fa1f71..f2780f7 100644
--- a/WebCore/editing/ApplyStyleCommand.cpp
+++ b/WebCore/editing/ApplyStyleCommand.cpp
@@ -142,7 +142,7 @@ void StyleChange::reconcileTextDecorationProperties(CSSMutableStyleDeclaration*
style->removeProperty(CSSPropertyTextDecoration);
}
-static int getIdentifierValue(CSSMutableStyleDeclaration* style, int propertyID)
+static int getIdentifierValue(CSSStyleDeclaration* style, int propertyID)
{
if (!style)
return 0;
@@ -477,7 +477,7 @@ void removeStylesAddedByNode(CSSMutableStyleDeclaration* editingStyle, Node* nod
parentStyle->diff(style.get());
style->diff(editingStyle);
}
-
+
ApplyStyleCommand::ApplyStyleCommand(Document* document, CSSStyleDeclaration* style, EditAction editingAction, EPropertyLevel propertyLevel)
: CompositeEditCommand(document)
, m_style(style->makeMutable())
@@ -793,7 +793,7 @@ void ApplyStyleCommand::cleanupUnstyledAppleStyleSpans(Node* dummySpanAncestor)
}
}
-HTMLElement* ApplyStyleCommand::splitAncestorsWithUnicodeBidi(Node* node, bool before, RefPtr<CSSPrimitiveValue> allowedDirection)
+HTMLElement* ApplyStyleCommand::splitAncestorsWithUnicodeBidi(Node* node, bool before, int allowedDirection)
{
// We are allowed to leave the highest ancestor with unicode-bidi unsplit if it is unicode-bidi: embed and direction: allowedDirection.
// In that case, we return the unsplit ancestor. Otherwise, we return 0.
@@ -803,16 +803,13 @@ HTMLElement* ApplyStyleCommand::splitAncestorsWithUnicodeBidi(Node* node, bool b
Node* highestAncestorWithUnicodeBidi = 0;
Node* nextHighestAncestorWithUnicodeBidi = 0;
- RefPtr<CSSPrimitiveValue> highestAncestorUnicodeBidi;
+ int highestAncestorUnicodeBidi = 0;
for (Node* n = node->parent(); n != block; n = n->parent()) {
- RefPtr<CSSValue> unicodeBidi = computedStyle(n)->getPropertyCSSValue(CSSPropertyUnicodeBidi);
- if (unicodeBidi) {
- ASSERT(unicodeBidi->isPrimitiveValue());
- if (static_cast<CSSPrimitiveValue*>(unicodeBidi.get())->getIdent() != CSSValueNormal) {
- highestAncestorUnicodeBidi = static_cast<CSSPrimitiveValue*>(unicodeBidi.get());
- nextHighestAncestorWithUnicodeBidi = highestAncestorWithUnicodeBidi;
- highestAncestorWithUnicodeBidi = n;
- }
+ int unicodeBidi = getIdentifierValue(computedStyle(n).get(), CSSPropertyUnicodeBidi);
+ if (unicodeBidi && unicodeBidi != CSSValueNormal) {
+ highestAncestorUnicodeBidi = unicodeBidi;
+ nextHighestAncestorWithUnicodeBidi = highestAncestorWithUnicodeBidi;
+ highestAncestorWithUnicodeBidi = n;
}
}
@@ -821,16 +818,14 @@ HTMLElement* ApplyStyleCommand::splitAncestorsWithUnicodeBidi(Node* node, bool b
HTMLElement* unsplitAncestor = 0;
- if (allowedDirection && highestAncestorUnicodeBidi->getIdent() != CSSValueBidiOverride) {
- RefPtr<CSSValue> highestAncestorDirection = computedStyle(highestAncestorWithUnicodeBidi)->getPropertyCSSValue(CSSPropertyDirection);
- ASSERT(highestAncestorDirection->isPrimitiveValue());
- if (static_cast<CSSPrimitiveValue*>(highestAncestorDirection.get())->getIdent() == allowedDirection->getIdent() && highestAncestorWithUnicodeBidi->isHTMLElement()) {
- if (!nextHighestAncestorWithUnicodeBidi)
- return static_cast<HTMLElement*>(highestAncestorWithUnicodeBidi);
+ if (allowedDirection && highestAncestorUnicodeBidi != CSSValueBidiOverride
+ && getIdentifierValue(computedStyle(highestAncestorWithUnicodeBidi).get(), CSSPropertyDirection) == allowedDirection
+ && highestAncestorWithUnicodeBidi->isHTMLElement()) {
+ if (!nextHighestAncestorWithUnicodeBidi)
+ return static_cast<HTMLElement*>(highestAncestorWithUnicodeBidi);
- unsplitAncestor = static_cast<HTMLElement*>(highestAncestorWithUnicodeBidi);
- highestAncestorWithUnicodeBidi = nextHighestAncestorWithUnicodeBidi;
- }
+ unsplitAncestor = static_cast<HTMLElement*>(highestAncestorWithUnicodeBidi);
+ highestAncestorWithUnicodeBidi = nextHighestAncestorWithUnicodeBidi;
}
// Split every ancestor through highest ancestor with embedding.
@@ -852,39 +847,34 @@ void ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock(Node* node, Node* unsp
if (!block)
return;
- Node* n = node->parent();
- while (n != block && n != unsplitAncestor) {
- Node* parent = n->parent();
- if (!n->isStyledElement()) {
- n = parent;
+ Node* parent = 0;
+ for (Node* n = node->parent(); n != block && n != unsplitAncestor; n = parent) {
+ parent = n->parent();
+ if (!n->isStyledElement())
continue;
- }
StyledElement* element = static_cast<StyledElement*>(n);
- RefPtr<CSSValue> unicodeBidi = computedStyle(element)->getPropertyCSSValue(CSSPropertyUnicodeBidi);
- if (unicodeBidi) {
- ASSERT(unicodeBidi->isPrimitiveValue());
- if (static_cast<CSSPrimitiveValue*>(unicodeBidi.get())->getIdent() != CSSValueNormal) {
- // FIXME: This code should really consider the mapped attribute 'dir', the inline style declaration,
- // and all matching style rules in order to determine how to best set the unicode-bidi property to 'normal'.
- // For now, it assumes that if the 'dir' attribute is present, then removing it will suffice, and
- // otherwise it sets the property in the inline style declaration.
- if (element->hasAttribute(dirAttr)) {
- // FIXME: If this is a BDO element, we should probably just remove it if it has no
- // other attributes, like we (should) do with B and I elements.
- removeNodeAttribute(element, dirAttr);
- } else {
- RefPtr<CSSMutableStyleDeclaration> inlineStyle = element->getInlineStyleDecl()->copy();
- inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal);
- inlineStyle->removeProperty(CSSPropertyDirection);
- setNodeAttribute(element, styleAttr, inlineStyle->cssText());
- // FIXME: should this be isSpanWithoutAttributesOrUnstyleStyleSpan? Need a test.
- if (isUnstyledStyleSpan(element))
- removeNodePreservingChildren(element);
- }
- }
+ int unicodeBidi = getIdentifierValue(computedStyle(element).get(), CSSPropertyUnicodeBidi);
+ if (!unicodeBidi || unicodeBidi == CSSValueNormal)
+ continue;
+
+ // FIXME: This code should really consider the mapped attribute 'dir', the inline style declaration,
+ // and all matching style rules in order to determine how to best set the unicode-bidi property to 'normal'.
+ // For now, it assumes that if the 'dir' attribute is present, then removing it will suffice, and
+ // otherwise it sets the property in the inline style declaration.
+ if (element->hasAttribute(dirAttr)) {
+ // FIXME: If this is a BDO element, we should probably just remove it if it has no
+ // other attributes, like we (should) do with B and I elements.
+ removeNodeAttribute(element, dirAttr);
+ } else {
+ RefPtr<CSSMutableStyleDeclaration> inlineStyle = element->getInlineStyleDecl()->copy();
+ inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal);
+ inlineStyle->removeProperty(CSSPropertyDirection);
+ setNodeAttribute(element, styleAttr, inlineStyle->cssText());
+ // FIXME: should this be isSpanWithoutAttributesOrUnstyleStyleSpan? Need a test.
+ if (isUnstyledStyleSpan(element))
+ removeNodePreservingChildren(element);
}
- n = parent;
}
}
@@ -931,21 +921,16 @@ void ApplyStyleCommand::applyInlineStyle(CSSMutableStyleDeclaration *style)
endDummySpanAncestor = dummySpanAncestorForNode(end.node());
}
- RefPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);
- RefPtr<CSSValue> direction;
+ int unicodeBidi = getIdentifierValue(style, CSSPropertyUnicodeBidi);
+ int direction = 0;
HTMLElement* startUnsplitAncestor = 0;
HTMLElement* endUnsplitAncestor = 0;
if (unicodeBidi) {
- RefPtr<CSSPrimitiveValue> allowedDirection;
- ASSERT(unicodeBidi->isPrimitiveValue());
- if (static_cast<CSSPrimitiveValue*>(unicodeBidi.get())->getIdent() == CSSValueEmbed) {
- // Leave alone an ancestor that provides the desired single level embedding, if there is one.
- direction = style->getPropertyCSSValue(CSSPropertyDirection);
- ASSERT(direction->isPrimitiveValue());
- allowedDirection = static_cast<CSSPrimitiveValue*>(direction.get());
- }
- startUnsplitAncestor = splitAncestorsWithUnicodeBidi(start.node(), true, allowedDirection);
- endUnsplitAncestor = splitAncestorsWithUnicodeBidi(end.node(), false, allowedDirection);
+ // Leave alone an ancestor that provides the desired single level embedding, if there is one.
+ if (unicodeBidi == CSSValueEmbed)
+ direction = getIdentifierValue(style, CSSPropertyDirection);
+ startUnsplitAncestor = splitAncestorsWithUnicodeBidi(start.node(), true, direction);
+ endUnsplitAncestor = splitAncestorsWithUnicodeBidi(end.node(), false, direction);
removeEmbeddingUpToEnclosingBlock(start.node(), startUnsplitAncestor);
removeEmbeddingUpToEnclosingBlock(end.node(), endUnsplitAncestor);
}
@@ -969,7 +954,7 @@ void ApplyStyleCommand::applyInlineStyle(CSSMutableStyleDeclaration *style)
if (embeddingRemoveStart != removeStart || embeddingRemoveEnd != end) {
RefPtr<CSSMutableStyleDeclaration> embeddingStyle = CSSMutableStyleDeclaration::create();
embeddingStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueEmbed);
- embeddingStyle->setProperty(CSSPropertyDirection, static_cast<CSSPrimitiveValue*>(direction.get())->getIdent());
+ embeddingStyle->setProperty(CSSPropertyDirection, direction);
if (comparePositions(embeddingRemoveStart, embeddingRemoveEnd) <= 0)
removeInlineStyle(embeddingStyle, embeddingRemoveStart, embeddingRemoveEnd);
@@ -1008,29 +993,17 @@ void ApplyStyleCommand::applyInlineStyle(CSSMutableStyleDeclaration *style)
// Avoid applying the unicode-bidi and direction properties beneath ancestors that already have them.
Node* startEnclosingBlock = enclosingBlock(start.node());
for (Node* n = start.node(); n != startEnclosingBlock; n = n->parent()) {
- if (n->isHTMLElement()) {
- RefPtr<CSSValue> ancestorUnicodeBidi = computedStyle(n)->getPropertyCSSValue(CSSPropertyUnicodeBidi);
- if (ancestorUnicodeBidi) {
- ASSERT(ancestorUnicodeBidi->isPrimitiveValue());
- if (static_cast<CSSPrimitiveValue*>(ancestorUnicodeBidi.get())->getIdent() == CSSValueEmbed) {
- embeddingApplyStart = positionInParentAfterNode(n);
- break;
- }
- }
+ if (n->isHTMLElement() && getIdentifierValue(computedStyle(n).get(), CSSPropertyUnicodeBidi) == CSSValueEmbed) {
+ embeddingApplyStart = positionInParentAfterNode(n);
+ break;
}
}
Node* endEnclosingBlock = enclosingBlock(end.node());
for (Node* n = end.node(); n != endEnclosingBlock; n = n->parent()) {
- if (n->isHTMLElement()) {
- RefPtr<CSSValue> ancestorUnicodeBidi = computedStyle(n)->getPropertyCSSValue(CSSPropertyUnicodeBidi);
- if (ancestorUnicodeBidi) {
- ASSERT(ancestorUnicodeBidi->isPrimitiveValue());
- if (static_cast<CSSPrimitiveValue*>(ancestorUnicodeBidi.get())->getIdent() == CSSValueEmbed) {
- embeddingApplyEnd = positionInParentBeforeNode(n);
- break;
- }
- }
+ if (n->isHTMLElement() && getIdentifierValue(computedStyle(n).get(), CSSPropertyUnicodeBidi) == CSSValueEmbed) {
+ embeddingApplyEnd = positionInParentBeforeNode(n);
+ break;
}
}
}
@@ -1039,7 +1012,7 @@ void ApplyStyleCommand::applyInlineStyle(CSSMutableStyleDeclaration *style)
if (embeddingApplyStart.isNotNull() && embeddingApplyEnd.isNotNull()) {
RefPtr<CSSMutableStyleDeclaration> embeddingStyle = CSSMutableStyleDeclaration::create();
embeddingStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueEmbed);
- embeddingStyle->setProperty(CSSPropertyDirection, static_cast<CSSPrimitiveValue*>(direction.get())->getIdent());
+ embeddingStyle->setProperty(CSSPropertyDirection, direction);
applyInlineStyleToRange(embeddingStyle.get(), embeddingApplyStart, embeddingApplyEnd);
}
diff --git a/WebCore/editing/ApplyStyleCommand.h b/WebCore/editing/ApplyStyleCommand.h
index cc20721..86c24da 100644
--- a/WebCore/editing/ApplyStyleCommand.h
+++ b/WebCore/editing/ApplyStyleCommand.h
@@ -106,7 +106,7 @@ private:
float computedFontSize(const Node*);
void joinChildTextNodes(Node*, const Position& start, const Position& end);
- HTMLElement* splitAncestorsWithUnicodeBidi(Node*, bool before, RefPtr<CSSPrimitiveValue> allowedDirection);
+ HTMLElement* splitAncestorsWithUnicodeBidi(Node*, bool before, int allowedDirection);
void removeEmbeddingUpToEnclosingBlock(Node* node, Node* unsplitAncestor);
void updateStartEnd(const Position& newStart, const Position& newEnd);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list