| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc. | 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc. |
| 3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 bool EditingStyle::textDirection(WritingDirection& writingDirection) const | 550 bool EditingStyle::textDirection(WritingDirection& writingDirection) const |
| 551 { | 551 { |
| 552 if (!m_mutableStyle) | 552 if (!m_mutableStyle) |
| 553 return false; | 553 return false; |
| 554 | 554 |
| 555 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = m_mutableStyle->getPropertyCSSVal
ue(CSSPropertyUnicodeBidi); | 555 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = m_mutableStyle->getPropertyCSSVal
ue(CSSPropertyUnicodeBidi); |
| 556 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) | 556 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) |
| 557 return false; | 557 return false; |
| 558 | 558 |
| 559 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->getVal
ueID(); | 559 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->getVal
ueID(); |
| 560 if (unicodeBidiValue == CSSValueEmbed) { | 560 if (isEmbedOrIsolate(unicodeBidiValue)) { |
| 561 RefPtrWillBeRawPtr<CSSValue> direction = m_mutableStyle->getPropertyCSSV
alue(CSSPropertyDirection); | 561 RefPtrWillBeRawPtr<CSSValue> direction = m_mutableStyle->getPropertyCSSV
alue(CSSPropertyDirection); |
| 562 if (!direction || !direction->isPrimitiveValue()) | 562 if (!direction || !direction->isPrimitiveValue()) |
| 563 return false; | 563 return false; |
| 564 | 564 |
| 565 writingDirection = toCSSPrimitiveValue(direction.get())->getValueID() ==
CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection; | 565 writingDirection = toCSSPrimitiveValue(direction.get())->getValueID() ==
CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection; |
| 566 | 566 |
| 567 return true; | 567 return true; |
| 568 } | 568 } |
| 569 | 569 |
| 570 if (unicodeBidiValue == CSSValueNormal) { | 570 if (unicodeBidiValue == CSSValueNormal) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 blockProperties->m_mutableStyle = m_mutableStyle->copyPropertiesInSet(blockP
ropertiesVector()); | 642 blockProperties->m_mutableStyle = m_mutableStyle->copyPropertiesInSet(blockP
ropertiesVector()); |
| 643 removeBlockProperties(); | 643 removeBlockProperties(); |
| 644 | 644 |
| 645 return blockProperties; | 645 return blockProperties; |
| 646 } | 646 } |
| 647 | 647 |
| 648 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::extractAndRemoveTextDirection
() | 648 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::extractAndRemoveTextDirection
() |
| 649 { | 649 { |
| 650 RefPtrWillBeRawPtr<EditingStyle> textDirection = EditingStyle::create(); | 650 RefPtrWillBeRawPtr<EditingStyle> textDirection = EditingStyle::create(); |
| 651 textDirection->m_mutableStyle = MutableStylePropertySet::create(HTMLQuirksMo
de); | 651 textDirection->m_mutableStyle = MutableStylePropertySet::create(HTMLQuirksMo
de); |
| 652 textDirection->m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueE
mbed, m_mutableStyle->propertyIsImportant(CSSPropertyUnicodeBidi)); | 652 textDirection->m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueI
solate, m_mutableStyle->propertyIsImportant(CSSPropertyUnicodeBidi)); |
| 653 textDirection->m_mutableStyle->setProperty(CSSPropertyDirection, m_mutableSt
yle->getPropertyValue(CSSPropertyDirection), | 653 textDirection->m_mutableStyle->setProperty(CSSPropertyDirection, m_mutableSt
yle->getPropertyValue(CSSPropertyDirection), |
| 654 m_mutableStyle->propertyIsImportant(CSSPropertyDirection)); | 654 m_mutableStyle->propertyIsImportant(CSSPropertyDirection)); |
| 655 | 655 |
| 656 m_mutableStyle->removeProperty(CSSPropertyUnicodeBidi); | 656 m_mutableStyle->removeProperty(CSSPropertyUnicodeBidi); |
| 657 m_mutableStyle->removeProperty(CSSPropertyDirection); | 657 m_mutableStyle->removeProperty(CSSPropertyDirection); |
| 658 | 658 |
| 659 return textDirection; | 659 return textDirection; |
| 660 } | 660 } |
| 661 | 661 |
| 662 void EditingStyle::removeBlockProperties() | 662 void EditingStyle::removeBlockProperties() |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 // and find the background color of the common ancestor. | 1339 // and find the background color of the common ancestor. |
| 1340 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare
ntBackgroundColor(style->m_mutableStyle.get()))) { | 1340 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare
ntBackgroundColor(style->m_mutableStyle.get()))) { |
| 1341 const EphemeralRange range(selection.toNormalizedEphemeralRange()); | 1341 const EphemeralRange range(selection.toNormalizedEphemeralRange()); |
| 1342 if (PassRefPtrWillBeRawPtr<CSSValue> value = backgroundColorValueInEffec
t(Range::commonAncestorContainer(range.startPosition().computeContainerNode(), r
ange.endPosition().computeContainerNode()))) | 1342 if (PassRefPtrWillBeRawPtr<CSSValue> value = backgroundColorValueInEffec
t(Range::commonAncestorContainer(range.startPosition().computeContainerNode(), r
ange.endPosition().computeContainerNode()))) |
| 1343 style->setProperty(CSSPropertyBackgroundColor, value->cssText()); | 1343 style->setProperty(CSSPropertyBackgroundColor, value->cssText()); |
| 1344 } | 1344 } |
| 1345 | 1345 |
| 1346 return style; | 1346 return style; |
| 1347 } | 1347 } |
| 1348 | 1348 |
| 1349 static bool isUnicodeBidiNestedOrMultipleEmbeddings(CSSValueID valueID) |
| 1350 { |
| 1351 return valueID == CSSValueEmbed || valueID == CSSValueBidiOverride |
| 1352 || valueID == CSSValueWebkitIsolate || valueID == CSSValueWebkitIsolateO
verride || valueID == CSSValueWebkitPlaintext |
| 1353 || valueID == CSSValueIsolate || valueID == CSSValueIsolateOverride || v
alueID == CSSValuePlaintext; |
| 1354 } |
| 1355 |
| 1349 WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
selection, EditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings) | 1356 WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
selection, EditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings) |
| 1350 { | 1357 { |
| 1351 hasNestedOrMultipleEmbeddings = true; | 1358 hasNestedOrMultipleEmbeddings = true; |
| 1352 | 1359 |
| 1353 if (selection.isNone()) | 1360 if (selection.isNone()) |
| 1354 return NaturalWritingDirection; | 1361 return NaturalWritingDirection; |
| 1355 | 1362 |
| 1356 Position position = mostForwardCaretPosition(selection.start()); | 1363 Position position = mostForwardCaretPosition(selection.start()); |
| 1357 | 1364 |
| 1358 Node* node = position.anchorNode(); | 1365 Node* node = position.anchorNode(); |
| 1359 if (!node) | 1366 if (!node) |
| 1360 return NaturalWritingDirection; | 1367 return NaturalWritingDirection; |
| 1361 | 1368 |
| 1362 Position end; | 1369 Position end; |
| 1363 if (selection.isRange()) { | 1370 if (selection.isRange()) { |
| 1364 end = mostBackwardCaretPosition(selection.end()); | 1371 end = mostBackwardCaretPosition(selection.end()); |
| 1365 | 1372 |
| 1366 ASSERT(end.document()); | 1373 ASSERT(end.document()); |
| 1367 Node* pastLast = Range::create(*end.document(), position.parentAnchoredE
quivalent(), end.parentAnchoredEquivalent())->pastLastNode(); | 1374 Node* pastLast = Range::create(*end.document(), position.parentAnchoredE
quivalent(), end.parentAnchoredEquivalent())->pastLastNode(); |
| 1368 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(*n)) { | 1375 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(*n)) { |
| 1369 if (!n->isStyledElement()) | 1376 if (!n->isStyledElement()) |
| 1370 continue; | 1377 continue; |
| 1371 | 1378 |
| 1372 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedS
tyleDeclaration::create(n); | 1379 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedS
tyleDeclaration::create(n); |
| 1373 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValu
e(CSSPropertyUnicodeBidi); | 1380 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValu
e(CSSPropertyUnicodeBidi); |
| 1374 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) | 1381 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) |
| 1375 continue; | 1382 continue; |
| 1376 | 1383 |
| 1377 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())
->getValueID(); | 1384 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())
->getValueID(); |
| 1378 if (unicodeBidiValue == CSSValueEmbed || unicodeBidiValue == CSSValu
eBidiOverride) | 1385 if (isUnicodeBidiNestedOrMultipleEmbeddings(unicodeBidiValue)) |
| 1379 return NaturalWritingDirection; | 1386 return NaturalWritingDirection; |
| 1380 } | 1387 } |
| 1381 } | 1388 } |
| 1382 | 1389 |
| 1383 if (selection.isCaret()) { | 1390 if (selection.isCaret()) { |
| 1384 WritingDirection direction; | 1391 WritingDirection direction; |
| 1385 if (typingStyle && typingStyle->textDirection(direction)) { | 1392 if (typingStyle && typingStyle->textDirection(direction)) { |
| 1386 hasNestedOrMultipleEmbeddings = false; | 1393 hasNestedOrMultipleEmbeddings = false; |
| 1387 return direction; | 1394 return direction; |
| 1388 } | 1395 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1404 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) | 1411 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) |
| 1405 continue; | 1412 continue; |
| 1406 | 1413 |
| 1407 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->ge
tValueID(); | 1414 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->ge
tValueID(); |
| 1408 if (unicodeBidiValue == CSSValueNormal) | 1415 if (unicodeBidiValue == CSSValueNormal) |
| 1409 continue; | 1416 continue; |
| 1410 | 1417 |
| 1411 if (unicodeBidiValue == CSSValueBidiOverride) | 1418 if (unicodeBidiValue == CSSValueBidiOverride) |
| 1412 return NaturalWritingDirection; | 1419 return NaturalWritingDirection; |
| 1413 | 1420 |
| 1414 ASSERT(unicodeBidiValue == CSSValueEmbed); | 1421 ASSERT(isEmbedOrIsolate(unicodeBidiValue)); |
| 1415 RefPtrWillBeRawPtr<CSSValue> direction = style->getPropertyCSSValue(CSSP
ropertyDirection); | 1422 RefPtrWillBeRawPtr<CSSValue> direction = style->getPropertyCSSValue(CSSP
ropertyDirection); |
| 1416 if (!direction || !direction->isPrimitiveValue()) | 1423 if (!direction || !direction->isPrimitiveValue()) |
| 1417 continue; | 1424 continue; |
| 1418 | 1425 |
| 1419 int directionValue = toCSSPrimitiveValue(direction.get())->getValueID(); | 1426 int directionValue = toCSSPrimitiveValue(direction.get())->getValueID(); |
| 1420 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) | 1427 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) |
| 1421 continue; | 1428 continue; |
| 1422 | 1429 |
| 1423 if (foundDirection != NaturalWritingDirection) | 1430 if (foundDirection != NaturalWritingDirection) |
| 1424 return NaturalWritingDirection; | 1431 return NaturalWritingDirection; |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1718 { | 1725 { |
| 1719 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1726 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
| 1720 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); | 1727 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); |
| 1721 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1728 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
| 1722 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1729 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
| 1723 } | 1730 } |
| 1724 return nullptr; | 1731 return nullptr; |
| 1725 } | 1732 } |
| 1726 | 1733 |
| 1727 } | 1734 } |
| OLD | NEW |