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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 } | 287 } |
290 | 288 |
291 void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element
, bool addDisplayInline, RangeFullySelectsNode rangeFullySelectsNode) | 289 void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element
, bool addDisplayInline, RangeFullySelectsNode rangeFullySelectsNode) |
292 { | 290 { |
293 const bool documentIsHTML = element.document().isHTMLDocument(); | 291 const bool documentIsHTML = element.document().isHTMLDocument(); |
294 appendOpenTag(out, element, 0); | 292 appendOpenTag(out, element, 0); |
295 | 293 |
296 const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldA
nnotate() || addDisplayInline); | 294 const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldA
nnotate() || addDisplayInline); |
297 const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldAp
plyWrappingStyle(element); | 295 const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldAp
plyWrappingStyle(element); |
298 | 296 |
299 if (element.hasAttributes()) { | 297 AttributeCollection attributes = element.attributes(); |
300 AttributeCollection attributes = element.attributes(); | 298 AttributeCollection::const_iterator end = attributes.end(); |
301 AttributeCollection::const_iterator end = attributes.end(); | 299 for (AttributeCollection::const_iterator it = attributes.begin(); it != end;
++it) { |
302 for (AttributeCollection::const_iterator it = attributes.begin(); it !=
end; ++it) { | 300 // We'll handle the style attribute separately, below. |
303 // We'll handle the style attribute separately, below. | 301 if (it->name() == styleAttr && shouldOverrideStyleAttr) |
304 if (it->name() == styleAttr && shouldOverrideStyleAttr) | 302 continue; |
305 continue; | 303 appendAttribute(out, element, *it, 0); |
306 appendAttribute(out, element, *it, 0); | |
307 } | |
308 } | 304 } |
309 | 305 |
310 if (shouldOverrideStyleAttr) { | 306 if (shouldOverrideStyleAttr) { |
311 RefPtrWillBeRawPtr<EditingStyle> newInlineStyle = nullptr; | 307 RefPtrWillBeRawPtr<EditingStyle> newInlineStyle = nullptr; |
312 | 308 |
313 if (shouldApplyWrappingStyle(element)) { | 309 if (shouldApplyWrappingStyle(element)) { |
314 newInlineStyle = m_wrappingStyle->copy(); | 310 newInlineStyle = m_wrappingStyle->copy(); |
315 newInlineStyle->removePropertiesInElementDefaultStyle(&element); | 311 newInlineStyle->removePropertiesInElementDefaultStyle(&element); |
316 newInlineStyle->removeStyleConflictingWithStyleOfElement(&element); | 312 newInlineStyle->removeStyleConflictingWithStyleOfElement(&element); |
317 } else | 313 } else |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 node->document().updateLayoutIgnorePendingStylesheets(); | 1088 node->document().updateLayoutIgnorePendingStylesheets(); |
1093 | 1089 |
1094 StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigation
Transition, nullptr, 0); | 1090 StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigation
Transition, nullptr, 0); |
1095 accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node))
; | 1091 accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node))
; |
1096 | 1092 |
1097 static const char* documentMarkup = "<!DOCTYPE html><meta name=\"viewport\"
content=\"width=device-width, user-scalable=0\">"; | 1093 static const char* documentMarkup = "<!DOCTYPE html><meta name=\"viewport\"
content=\"width=device-width, user-scalable=0\">"; |
1098 return documentMarkup + accumulator.takeResults(); | 1094 return documentMarkup + accumulator.takeResults(); |
1099 } | 1095 } |
1100 | 1096 |
1101 } | 1097 } |
OLD | NEW |