OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. |
4 * Copyright (C) 2011 Igalia S.L. | 4 * Copyright (C) 2011 Igalia S.L. |
5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 { | 94 { |
95 Vector<AttributeChange> changes; | 95 Vector<AttributeChange> changes; |
96 | 96 |
97 KURL parsedBaseURL(ParsedURLString, baseURL); | 97 KURL parsedBaseURL(ParsedURLString, baseURL); |
98 | 98 |
99 for (Element* element = ElementTraversal::firstWithin(fragment); element; el
ement = ElementTraversal::next(*element, &fragment)) { | 99 for (Element* element = ElementTraversal::firstWithin(fragment); element; el
ement = ElementTraversal::next(*element, &fragment)) { |
100 if (!element->hasAttributes()) | 100 if (!element->hasAttributes()) |
101 continue; | 101 continue; |
102 unsigned length = element->attributeCount(); | 102 unsigned length = element->attributeCount(); |
103 for (unsigned i = 0; i < length; i++) { | 103 for (unsigned i = 0; i < length; i++) { |
104 const Attribute* attribute = element->attributeItem(i); | 104 const Attribute& attribute = element->attributeItem(i); |
105 if (element->isURLAttribute(*attribute) && !attribute->value().isEmp
ty()) | 105 if (element->isURLAttribute(attribute) && !attribute.value().isEmpty
()) |
106 changes.append(AttributeChange(element, attribute->name(), KURL(
parsedBaseURL, attribute->value()).string())); | 106 changes.append(AttributeChange(element, attribute.name(), KURL(p
arsedBaseURL, attribute.value()).string())); |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 size_t numChanges = changes.size(); | 110 size_t numChanges = changes.size(); |
111 for (size_t i = 0; i < numChanges; ++i) | 111 for (size_t i = 0; i < numChanges; ++i) |
112 changes[i].apply(); | 112 changes[i].apply(); |
113 } | 113 } |
114 | 114 |
115 class StyledMarkupAccumulator FINAL : public MarkupAccumulator { | 115 class StyledMarkupAccumulator FINAL : public MarkupAccumulator { |
116 public: | 116 public: |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 273 |
274 void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element
, bool addDisplayInline, RangeFullySelectsNode rangeFullySelectsNode) | 274 void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element
, bool addDisplayInline, RangeFullySelectsNode rangeFullySelectsNode) |
275 { | 275 { |
276 const bool documentIsHTML = element.document().isHTMLDocument(); | 276 const bool documentIsHTML = element.document().isHTMLDocument(); |
277 appendOpenTag(out, element, 0); | 277 appendOpenTag(out, element, 0); |
278 | 278 |
279 const unsigned length = element.hasAttributes() ? element.attributeCount() :
0; | 279 const unsigned length = element.hasAttributes() ? element.attributeCount() :
0; |
280 const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldA
nnotate() || addDisplayInline); | 280 const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldA
nnotate() || addDisplayInline); |
281 const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldAp
plyWrappingStyle(element); | 281 const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldAp
plyWrappingStyle(element); |
282 for (unsigned i = 0; i < length; ++i) { | 282 for (unsigned i = 0; i < length; ++i) { |
283 const Attribute* attribute = element.attributeItem(i); | 283 const Attribute& attribute = element.attributeItem(i); |
284 // We'll handle the style attribute separately, below. | 284 // We'll handle the style attribute separately, below. |
285 if (attribute->name() == styleAttr && shouldOverrideStyleAttr) | 285 if (attribute.name() == styleAttr && shouldOverrideStyleAttr) |
286 continue; | 286 continue; |
287 appendAttribute(out, element, *attribute, 0); | 287 appendAttribute(out, element, attribute, 0); |
288 } | 288 } |
289 | 289 |
290 if (shouldOverrideStyleAttr) { | 290 if (shouldOverrideStyleAttr) { |
291 RefPtr<EditingStyle> newInlineStyle; | 291 RefPtr<EditingStyle> newInlineStyle; |
292 | 292 |
293 if (shouldApplyWrappingStyle(element)) { | 293 if (shouldApplyWrappingStyle(element)) { |
294 newInlineStyle = m_wrappingStyle->copy(); | 294 newInlineStyle = m_wrappingStyle->copy(); |
295 newInlineStyle->removePropertiesInElementDefaultStyle(&element); | 295 newInlineStyle->removePropertiesInElementDefaultStyle(&element); |
296 newInlineStyle->removeStyleConflictingWithStyleOfNode(&element); | 296 newInlineStyle->removeStyleConflictingWithStyleOfNode(&element); |
297 } else | 297 } else |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 return; | 1048 return; |
1049 | 1049 |
1050 RefPtr<Text> textNode = toText(node.get()); | 1050 RefPtr<Text> textNode = toText(node.get()); |
1051 RefPtr<Text> textNext = toText(next); | 1051 RefPtr<Text> textNext = toText(next); |
1052 textNode->appendData(textNext->data()); | 1052 textNode->appendData(textNext->data()); |
1053 if (textNext->parentNode()) // Might have been removed by mutation event. | 1053 if (textNext->parentNode()) // Might have been removed by mutation event. |
1054 textNext->remove(exceptionState); | 1054 textNext->remove(exceptionState); |
1055 } | 1055 } |
1056 | 1056 |
1057 } | 1057 } |
OLD | NEW |