OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty(ele ment->inlineStyle()); | 393 RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty(ele ment->inlineStyle()); |
394 float currentFontSize = computedFontSize(node); | 394 float currentFontSize = computedFontSize(node); |
395 float desiredFontSize = max(MinimumFontSize, startingFontSizes.get(node) + style->fontSizeDelta()); | 395 float desiredFontSize = max(MinimumFontSize, startingFontSizes.get(node) + style->fontSizeDelta()); |
396 RefPtr<CSSValue> value = inlineStyle->getPropertyCSSValue(CSSPropertyFon tSize); | 396 RefPtr<CSSValue> value = inlineStyle->getPropertyCSSValue(CSSPropertyFon tSize); |
397 if (value) { | 397 if (value) { |
398 element->removeInlineStyleProperty(CSSPropertyFontSize); | 398 element->removeInlineStyleProperty(CSSPropertyFontSize); |
399 currentFontSize = computedFontSize(node); | 399 currentFontSize = computedFontSize(node); |
400 } | 400 } |
401 if (currentFontSize != desiredFontSize) { | 401 if (currentFontSize != desiredFontSize) { |
402 inlineStyle->setProperty(CSSPropertyFontSize, cssValuePool().createV alue(desiredFontSize, CSSPrimitiveValue::CSS_PX), false); | 402 inlineStyle->setProperty(CSSPropertyFontSize, cssValuePool().createV alue(desiredFontSize, CSSPrimitiveValue::CSS_PX), false); |
403 setNodeAttribute(element.get(), styleAttr, inlineStyle->asText()); | 403 setNodeAttribute(element.get(), styleAttr, AtomicString(inlineStyle- >asText())); |
Inactive
2013/12/09 22:44:10
It seems several callers of asText() expect an Ato
abarth-chromium
2013/12/12 18:37:51
Hum... I don't have a strong opinion here.
| |
404 } | 404 } |
405 if (inlineStyle->isEmpty()) { | 405 if (inlineStyle->isEmpty()) { |
406 removeNodeAttribute(element.get(), styleAttr); | 406 removeNodeAttribute(element.get(), styleAttr); |
407 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element.get())) | 407 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element.get())) |
408 unstyledSpans.append(element.release()); | 408 unstyledSpans.append(element.release()); |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 size_t size = unstyledSpans.size(); | 412 size_t size = unstyledSpans.size(); |
413 for (size_t i = 0; i < size; ++i) | 413 for (size_t i = 0; i < size; ++i) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 // For now, it assumes that if the 'dir' attribute is present, then remo ving it will suffice, and | 512 // For now, it assumes that if the 'dir' attribute is present, then remo ving it will suffice, and |
513 // otherwise it sets the property in the inline style declaration. | 513 // otherwise it sets the property in the inline style declaration. |
514 if (element->hasAttribute(dirAttr)) { | 514 if (element->hasAttribute(dirAttr)) { |
515 // FIXME: If this is a BDO element, we should probably just remove i t if it has no | 515 // FIXME: If this is a BDO element, we should probably just remove i t if it has no |
516 // other attributes, like we (should) do with B and I elements. | 516 // other attributes, like we (should) do with B and I elements. |
517 removeNodeAttribute(element, dirAttr); | 517 removeNodeAttribute(element, dirAttr); |
518 } else { | 518 } else { |
519 RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty (element->inlineStyle()); | 519 RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty (element->inlineStyle()); |
520 inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal); | 520 inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal); |
521 inlineStyle->removeProperty(CSSPropertyDirection); | 521 inlineStyle->removeProperty(CSSPropertyDirection); |
522 setNodeAttribute(element, styleAttr, inlineStyle->asText()); | 522 setNodeAttribute(element, styleAttr, AtomicString(inlineStyle->asTex t())); |
523 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element)) | 523 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element)) |
524 removeNodePreservingChildren(element); | 524 removeNodePreservingChildren(element); |
525 } | 525 } |
526 } | 526 } |
527 } | 527 } |
528 | 528 |
529 static Node* highestEmbeddingAncestor(Node* startNode, Node* enclosingNode) | 529 static Node* highestEmbeddingAncestor(Node* startNode, Node* enclosingNode) |
530 { | 530 { |
531 for (Node* n = startNode; n && n != enclosingNode; n = n->parentNode()) { | 531 for (Node* n = startNode; n && n != enclosingNode; n = n->parentNode()) { |
532 if (n->isHTMLElement() && getIdentifierValue(CSSComputedStyleDeclaration ::create(n).get(), CSSPropertyUnicodeBidi) == CSSValueEmbed) | 532 if (n->isHTMLElement() && getIdentifierValue(CSSComputedStyleDeclaration ::create(n).get(), CSSPropertyUnicodeBidi) == CSSValueEmbed) |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
759 // node isn't fully selected. | 759 // node isn't fully selected. |
760 if (pastEndNode && pastEndNode->isDescendantOf(node.get())) | 760 if (pastEndNode && pastEndNode->isDescendantOf(node.get())) |
761 break; | 761 break; |
762 // Add to this element's inline style and skip over its contents. | 762 // Add to this element's inline style and skip over its contents. |
763 HTMLElement* element = toHTMLElement(node); | 763 HTMLElement* element = toHTMLElement(node); |
764 next = NodeTraversal::nextSkippingChildren(*node); | 764 next = NodeTraversal::nextSkippingChildren(*node); |
765 if (!style->style()) | 765 if (!style->style()) |
766 continue; | 766 continue; |
767 RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty (element->inlineStyle()); | 767 RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty (element->inlineStyle()); |
768 inlineStyle->mergeAndOverrideOnConflict(style->style()); | 768 inlineStyle->mergeAndOverrideOnConflict(style->style()); |
769 setNodeAttribute(element, styleAttr, inlineStyle->asText()); | 769 setNodeAttribute(element, styleAttr, AtomicString(inlineStyle->asTex t())); |
770 continue; | 770 continue; |
771 } | 771 } |
772 | 772 |
773 if (isBlock(node.get())) | 773 if (isBlock(node.get())) |
774 continue; | 774 continue; |
775 | 775 |
776 if (node->childNodeCount()) { | 776 if (node->childNodeCount()) { |
777 if (node->contains(pastEndNode.get()) || containsNonEditableRegion(* node) || !node->parentNode()->rendererIsEditable()) | 777 if (node->contains(pastEndNode.get()) || containsNonEditableRegion(* node) || !node->parentNode()->rendererIsEditable()) |
778 continue; | 778 continue; |
779 if (editingIgnoresContent(node.get())) { | 779 if (editingIgnoresContent(node.get())) { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
998 | 998 |
999 RefPtr<EditingStyle> newInlineStyle = style; | 999 RefPtr<EditingStyle> newInlineStyle = style; |
1000 if (node->isHTMLElement() && toHTMLElement(node)->inlineStyle()) { | 1000 if (node->isHTMLElement() && toHTMLElement(node)->inlineStyle()) { |
1001 newInlineStyle = style->copy(); | 1001 newInlineStyle = style->copy(); |
1002 newInlineStyle->mergeInlineStyleOfElement(toHTMLElement(node), EditingSt yle::OverrideValues); | 1002 newInlineStyle->mergeInlineStyleOfElement(toHTMLElement(node), EditingSt yle::OverrideValues); |
1003 } | 1003 } |
1004 | 1004 |
1005 // Since addInlineStyleIfNeeded can't add styles to block-flow render object s, add style attribute instead. | 1005 // Since addInlineStyleIfNeeded can't add styles to block-flow render object s, add style attribute instead. |
1006 // FIXME: applyInlineStyleToRange should be used here instead. | 1006 // FIXME: applyInlineStyleToRange should be used here instead. |
1007 if ((node->renderer()->isRenderBlockFlow() || node->childNodeCount()) && nod e->isHTMLElement()) { | 1007 if ((node->renderer()->isRenderBlockFlow() || node->childNodeCount()) && nod e->isHTMLElement()) { |
1008 setNodeAttribute(toHTMLElement(node), styleAttr, newInlineStyle->style() ->asText()); | 1008 setNodeAttribute(toHTMLElement(node), styleAttr, AtomicString(newInlineS tyle->style()->asText())); |
1009 return; | 1009 return; |
1010 } | 1010 } |
1011 | 1011 |
1012 if (node->renderer()->isText() && static_cast<RenderText*>(node->renderer()) ->isAllCollapsibleWhitespace()) | 1012 if (node->renderer()->isText() && static_cast<RenderText*>(node->renderer()) ->isAllCollapsibleWhitespace()) |
1013 return; | 1013 return; |
1014 | 1014 |
1015 // We can't wrap node with the styled element here because new styled elemen t will never be removed if we did. | 1015 // We can't wrap node with the styled element here because new styled elemen t will never be removed if we did. |
1016 // If we modified the child pointer in pushDownInlineStyleAroundNode to poin t to new style element | 1016 // If we modified the child pointer in pushDownInlineStyleAroundNode to poin t to new style element |
1017 // then we fall into an infinite loop where we keep removing and adding styl ed element wrapping node. | 1017 // then we fall into an infinite loop where we keep removing and adding styl ed element wrapping node. |
1018 addInlineStyleIfNeeded(newInlineStyle.get(), node, node, DoNotAddStyledEleme nt); | 1018 addInlineStyleIfNeeded(newInlineStyle.get(), node, node, DoNotAddStyledEleme nt); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1380 return; | 1380 return; |
1381 | 1381 |
1382 String cssStyle = styleChange.cssStyle(); | 1382 String cssStyle = styleChange.cssStyle(); |
1383 StringBuilder cssText; | 1383 StringBuilder cssText; |
1384 cssText.append(cssStyle); | 1384 cssText.append(cssStyle); |
1385 if (const StylePropertySet* decl = block->inlineStyle()) { | 1385 if (const StylePropertySet* decl = block->inlineStyle()) { |
1386 if (!cssStyle.isEmpty()) | 1386 if (!cssStyle.isEmpty()) |
1387 cssText.append(' '); | 1387 cssText.append(' '); |
1388 cssText.append(decl->asText()); | 1388 cssText.append(decl->asText()); |
1389 } | 1389 } |
1390 setNodeAttribute(block, styleAttr, cssText.toString()); | 1390 setNodeAttribute(block, styleAttr, cssText.toAtomicString()); |
1391 } | 1391 } |
1392 | 1392 |
1393 void ApplyStyleCommand::addInlineStyleIfNeeded(EditingStyle* style, PassRefPtr<N ode> passedStart, PassRefPtr<Node> passedEnd, EAddStyledElement addStyledElement ) | 1393 void ApplyStyleCommand::addInlineStyleIfNeeded(EditingStyle* style, PassRefPtr<N ode> passedStart, PassRefPtr<Node> passedEnd, EAddStyledElement addStyledElement ) |
1394 { | 1394 { |
1395 if (!passedStart || !passedEnd || !passedStart->inDocument() || !passedEnd-> inDocument()) | 1395 if (!passedStart || !passedEnd || !passedStart->inDocument() || !passedEnd-> inDocument()) |
1396 return; | 1396 return; |
1397 | 1397 |
1398 RefPtr<Node> start = passedStart; | 1398 RefPtr<Node> start = passedStart; |
1399 RefPtr<Node> dummyElement; | 1399 RefPtr<Node> dummyElement; |
1400 StyleChange styleChange(style, positionToComputeInlineStyleChange(start, dum myElement)); | 1400 StyleChange styleChange(style, positionToComputeInlineStyleChange(start, dum myElement)); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1547 String textToMove = nextText->data(); | 1547 String textToMove = nextText->data(); |
1548 insertTextIntoNode(childText, childText->length(), textToMove); | 1548 insertTextIntoNode(childText, childText->length(), textToMove); |
1549 removeNode(next); | 1549 removeNode(next); |
1550 // don't move child node pointer. it may want to merge with more text no des. | 1550 // don't move child node pointer. it may want to merge with more text no des. |
1551 } | 1551 } |
1552 | 1552 |
1553 updateStartEnd(newStart, newEnd); | 1553 updateStartEnd(newStart, newEnd); |
1554 } | 1554 } |
1555 | 1555 |
1556 } | 1556 } |
OLD | NEW |