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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 namespace blink { | 109 namespace blink { |
110 | 110 |
111 static void completeURLs(DocumentFragment& fragment, const String& baseURL) | 111 static void completeURLs(DocumentFragment& fragment, const String& baseURL) |
112 { | 112 { |
113 WillBeHeapVector<AttributeChange> changes; | 113 WillBeHeapVector<AttributeChange> changes; |
114 | 114 |
115 KURL parsedBaseURL(ParsedURLString, baseURL); | 115 KURL parsedBaseURL(ParsedURLString, baseURL); |
116 | 116 |
117 for (Element* element = ElementTraversal::firstWithin(fragment); element; el
ement = ElementTraversal::next(*element, &fragment)) { | 117 for (Element* element = ElementTraversal::firstWithin(fragment); element; el
ement = ElementTraversal::next(*element, &fragment)) { |
118 if (!element->hasAttributes()) | |
119 continue; | |
120 AttributeCollection attributes = element->attributes(); | 118 AttributeCollection attributes = element->attributes(); |
121 AttributeCollection::const_iterator end = attributes.end(); | 119 AttributeCollection::const_iterator end = attributes.end(); |
122 for (AttributeCollection::const_iterator it = attributes.begin(); it !=
end; ++it) { | 120 for (AttributeCollection::const_iterator it = attributes.begin(); it !=
end; ++it) { |
123 if (element->isURLAttribute(*it) && !it->value().isEmpty()) | 121 if (element->isURLAttribute(*it) && !it->value().isEmpty()) |
124 changes.append(AttributeChange(element, it->name(), KURL(parsedB
aseURL, it->value()).string())); | 122 changes.append(AttributeChange(element, it->name(), KURL(parsedB
aseURL, it->value()).string())); |
125 } | 123 } |
126 } | 124 } |
127 | 125 |
128 size_t numChanges = changes.size(); | 126 size_t numChanges = changes.size(); |
129 for (size_t i = 0; i < numChanges; ++i) | 127 for (size_t i = 0; i < numChanges; ++i) |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } | 288 } |
291 | 289 |
292 void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element
, bool addDisplayInline, RangeFullySelectsNode rangeFullySelectsNode) | 290 void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element
, bool addDisplayInline, RangeFullySelectsNode rangeFullySelectsNode) |
293 { | 291 { |
294 const bool documentIsHTML = element.document().isHTMLDocument(); | 292 const bool documentIsHTML = element.document().isHTMLDocument(); |
295 appendOpenTag(out, element, 0); | 293 appendOpenTag(out, element, 0); |
296 | 294 |
297 const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldA
nnotate() || addDisplayInline); | 295 const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldA
nnotate() || addDisplayInline); |
298 const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldAp
plyWrappingStyle(element); | 296 const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldAp
plyWrappingStyle(element); |
299 | 297 |
300 if (element.hasAttributes()) { | 298 AttributeCollection attributes = element.attributes(); |
301 AttributeCollection attributes = element.attributes(); | 299 AttributeCollection::const_iterator end = attributes.end(); |
302 AttributeCollection::const_iterator end = attributes.end(); | 300 for (AttributeCollection::const_iterator it = attributes.begin(); it != end;
++it) { |
303 for (AttributeCollection::const_iterator it = attributes.begin(); it !=
end; ++it) { | 301 // We'll handle the style attribute separately, below. |
304 // We'll handle the style attribute separately, below. | 302 if (it->name() == styleAttr && shouldOverrideStyleAttr) |
305 if (it->name() == styleAttr && shouldOverrideStyleAttr) | 303 continue; |
306 continue; | 304 appendAttribute(out, element, *it, 0); |
307 appendAttribute(out, element, *it, 0); | |
308 } | |
309 } | 305 } |
310 | 306 |
311 if (shouldOverrideStyleAttr) { | 307 if (shouldOverrideStyleAttr) { |
312 RefPtrWillBeRawPtr<EditingStyle> newInlineStyle = nullptr; | 308 RefPtrWillBeRawPtr<EditingStyle> newInlineStyle = nullptr; |
313 | 309 |
314 if (shouldApplyWrappingStyle(element)) { | 310 if (shouldApplyWrappingStyle(element)) { |
315 newInlineStyle = m_wrappingStyle->copy(); | 311 newInlineStyle = m_wrappingStyle->copy(); |
316 newInlineStyle->removePropertiesInElementDefaultStyle(&element); | 312 newInlineStyle->removePropertiesInElementDefaultStyle(&element); |
317 newInlineStyle->removeStyleConflictingWithStyleOfElement(&element); | 313 newInlineStyle->removeStyleConflictingWithStyleOfElement(&element); |
318 } else | 314 } else |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 node->document().updateLayoutIgnorePendingStylesheets(); | 1089 node->document().updateLayoutIgnorePendingStylesheets(); |
1094 | 1090 |
1095 StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigation
Transition, nullptr, 0); | 1091 StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigation
Transition, nullptr, 0); |
1096 accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node))
; | 1092 accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node))
; |
1097 | 1093 |
1098 static const char* documentMarkup = "<!DOCTYPE html><meta name=\"viewport\"
content=\"width=device-width, user-scalable=0\">"; | 1094 static const char* documentMarkup = "<!DOCTYPE html><meta name=\"viewport\"
content=\"width=device-width, user-scalable=0\">"; |
1099 return documentMarkup + accumulator.takeResults(); | 1095 return documentMarkup + accumulator.takeResults(); |
1100 } | 1096 } |
1101 | 1097 |
1102 } | 1098 } |
OLD | NEW |