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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 continue; | 389 continue; |
390 } | 390 } |
391 lastStyledNode = node; | 391 lastStyledNode = node; |
392 | 392 |
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); | |
vanihegde
2014/01/06 09:01:37
computedFontSize() is already done at line 394.
ojan
2014/01/06 18:55:41
Doesn't the line above this invalidate the compute
vanihegde
2014/01/07 08:30:46
Yes, it does. Sorry I missed it!
| |
400 } | 399 } |
401 if (currentFontSize != desiredFontSize) { | 400 if (currentFontSize != desiredFontSize) { |
402 inlineStyle->setProperty(CSSPropertyFontSize, cssValuePool().createV alue(desiredFontSize, CSSPrimitiveValue::CSS_PX), false); | 401 inlineStyle->setProperty(CSSPropertyFontSize, cssValuePool().createV alue(desiredFontSize, CSSPrimitiveValue::CSS_PX), false); |
403 setNodeAttribute(element.get(), styleAttr, AtomicString(inlineStyle- >asText())); | 402 setNodeAttribute(element.get(), styleAttr, AtomicString(inlineStyle- >asText())); |
404 } | 403 } |
405 if (inlineStyle->isEmpty()) { | 404 if (inlineStyle->isEmpty()) { |
406 removeNodeAttribute(element.get(), styleAttr); | 405 removeNodeAttribute(element.get(), styleAttr); |
407 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element.get())) | 406 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element.get())) |
408 unstyledSpans.append(element.release()); | 407 unstyledSpans.append(element.release()); |
409 } | 408 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 } | 488 } |
490 return unsplitAncestor; | 489 return unsplitAncestor; |
491 } | 490 } |
492 | 491 |
493 void ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock(Node* node, Node* unsp litAncestor) | 492 void ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock(Node* node, Node* unsp litAncestor) |
494 { | 493 { |
495 Node* block = enclosingBlock(node); | 494 Node* block = enclosingBlock(node); |
496 if (!block) | 495 if (!block) |
497 return; | 496 return; |
498 | 497 |
499 Node* parent = 0; | 498 for (Node* n = node->parentNode(); n != block && n != unsplitAncestor; n = n ->parentNode()) { |
500 for (Node* n = node->parentNode(); n != block && n != unsplitAncestor; n = p arent) { | |
501 parent = n->parentNode(); | |
502 if (!n->isStyledElement()) | 499 if (!n->isStyledElement()) |
503 continue; | 500 continue; |
504 | 501 |
505 Element* element = toElement(n); | 502 Element* element = toElement(n); |
506 int unicodeBidi = getIdentifierValue(CSSComputedStyleDeclaration::create (element).get(), CSSPropertyUnicodeBidi); | 503 int unicodeBidi = getIdentifierValue(CSSComputedStyleDeclaration::create (element).get(), CSSPropertyUnicodeBidi); |
507 if (!unicodeBidi || unicodeBidi == CSSValueNormal) | 504 if (!unicodeBidi || unicodeBidi == CSSValueNormal) |
508 continue; | 505 continue; |
509 | 506 |
510 // FIXME: This code should really consider the mapped attribute 'dir', t he inline style declaration, | 507 // FIXME: This code should really consider the mapped attribute 'dir', t he inline style declaration, |
511 // and all matching style rules in order to determine how to best set th e unicode-bidi property to 'normal'. | 508 // and all matching style rules in order to determine how to best set th e unicode-bidi property to 'normal'. |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
688 // if they want style applied to the empty line. | 685 // if they want style applied to the empty line. |
689 if (start == end && start.deprecatedNode()->hasTagName(brTag)) | 686 if (start == end && start.deprecatedNode()->hasTagName(brTag)) |
690 pastEndNode = NodeTraversal::next(*start.deprecatedNode()); | 687 pastEndNode = NodeTraversal::next(*start.deprecatedNode()); |
691 | 688 |
692 // Start from the highest fully selected ancestor so that we can modify the fully selected node. | 689 // Start from the highest fully selected ancestor so that we can modify the fully selected node. |
693 // e.g. When applying font-size: large on <font color="blue">hello</font>, w e need to include the font element in our run | 690 // e.g. When applying font-size: large on <font color="blue">hello</font>, w e need to include the font element in our run |
694 // to generate <font color="blue" size="4">hello</font> instead of <font col or="blue"><font size="4">hello</font></font> | 691 // to generate <font color="blue" size="4">hello</font> instead of <font col or="blue"><font size="4">hello</font></font> |
695 RefPtr<Range> range = Range::create(startNode->document(), start, end); | 692 RefPtr<Range> range = Range::create(startNode->document(), start, end); |
696 Element* editableRoot = startNode->rootEditableElement(); | 693 Element* editableRoot = startNode->rootEditableElement(); |
697 if (startNode != editableRoot) { | 694 if (startNode != editableRoot) { |
698 while (editableRoot && startNode->parentNode() != editableRoot && isNode VisiblyContainedWithin(startNode->parentNode(), range.get())) | 695 Node* parentNode = startNode->parentNode(); |
ojan
2014/01/06 18:55:41
I'm not sure this code is any cleaner and I'd be s
vanihegde
2014/01/07 08:30:46
Reverting.
| |
699 startNode = startNode->parentNode(); | 696 while (editableRoot && parentNode != editableRoot && isNodeVisiblyContai nedWithin(parentNode, range.get())) { |
697 startNode = parentNode; | |
698 parentNode = startNode->parentNode(); | |
699 } | |
700 } | 700 } |
701 | 701 |
702 applyInlineStyleToNodeRange(style, startNode, pastEndNode); | 702 applyInlineStyleToNodeRange(style, startNode, pastEndNode); |
703 } | 703 } |
704 | 704 |
705 static bool containsNonEditableRegion(Node& node) | 705 static bool containsNonEditableRegion(Node& node) |
706 { | 706 { |
707 if (!node.rendererIsEditable()) | 707 if (!node.rendererIsEditable()) |
708 return true; | 708 return true; |
709 | 709 |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1326 } | 1326 } |
1327 | 1327 |
1328 return false; | 1328 return false; |
1329 } | 1329 } |
1330 | 1330 |
1331 void ApplyStyleCommand::surroundNodeRangeWithElement(PassRefPtr<Node> passedStar tNode, PassRefPtr<Node> endNode, PassRefPtr<Element> elementToInsert) | 1331 void ApplyStyleCommand::surroundNodeRangeWithElement(PassRefPtr<Node> passedStar tNode, PassRefPtr<Node> endNode, PassRefPtr<Element> elementToInsert) |
1332 { | 1332 { |
1333 ASSERT(passedStartNode); | 1333 ASSERT(passedStartNode); |
1334 ASSERT(endNode); | 1334 ASSERT(endNode); |
1335 ASSERT(elementToInsert); | 1335 ASSERT(elementToInsert); |
1336 RefPtr<Node> startNode = passedStartNode; | 1336 RefPtr<Node> node = passedStartNode; |
1337 RefPtr<Element> element = elementToInsert; | 1337 RefPtr<Element> element = elementToInsert; |
1338 | 1338 |
1339 insertNodeBefore(element, startNode); | 1339 insertNodeBefore(element, node); |
1340 | 1340 |
1341 RefPtr<Node> node = startNode; | |
1342 while (node) { | 1341 while (node) { |
1343 RefPtr<Node> next = node->nextSibling(); | 1342 RefPtr<Node> next = node->nextSibling(); |
1344 if (node->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable)) { | 1343 if (node->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable)) { |
1345 removeNode(node); | 1344 removeNode(node); |
1346 appendNode(node, element); | 1345 appendNode(node, element); |
1347 } | 1346 } |
1348 if (node == endNode) | 1347 if (node == endNode) |
1349 break; | 1348 break; |
1350 node = next; | 1349 node = next; |
1351 } | 1350 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1543 String textToMove = nextText->data(); | 1542 String textToMove = nextText->data(); |
1544 insertTextIntoNode(childText, childText->length(), textToMove); | 1543 insertTextIntoNode(childText, childText->length(), textToMove); |
1545 removeNode(next); | 1544 removeNode(next); |
1546 // don't move child node pointer. it may want to merge with more text no des. | 1545 // don't move child node pointer. it may want to merge with more text no des. |
1547 } | 1546 } |
1548 | 1547 |
1549 updateStartEnd(newStart, newEnd); | 1548 updateStartEnd(newStart, newEnd); |
1550 } | 1549 } |
1551 | 1550 |
1552 } | 1551 } |
OLD | NEW |