| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 using namespace Unicode; | 177 using namespace Unicode; |
| 178 | 178 |
| 179 namespace WebCore { | 179 namespace WebCore { |
| 180 | 180 |
| 181 using namespace HTMLNames; | 181 using namespace HTMLNames; |
| 182 | 182 |
| 183 static const double cDefaultIncrementalRenderingSuppressionTimeoutInSeconds = 5; | 183 static const double cDefaultIncrementalRenderingSuppressionTimeoutInSeconds = 5; |
| 184 | 184 |
| 185 static const unsigned cMaxWriteRecursionDepth = 21; | 185 static const unsigned cMaxWriteRecursionDepth = 21; |
| 186 | 186 |
| 187 // This amount of time must have elapsed before we will even consider scheduling
a layout without a delay. | |
| 188 // FIXME: For faster machines this value can really be lowered to 200. 250 is a
dequate, but a little high | |
| 189 // for dual G5s. :) | |
| 190 static const int cLayoutScheduleThreshold = 250; | |
| 191 | 187 |
| 192 // DOM Level 2 says (letters added): | 188 // DOM Level 2 says (letters added): |
| 193 // | 189 // |
| 194 // a) Name start characters must have one of the categories Ll, Lu, Lo, Lt, Nl. | 190 // a) Name start characters must have one of the categories Ll, Lu, Lo, Lt, Nl. |
| 195 // b) Name characters other than Name-start characters must have one of the cate
gories Mc, Me, Mn, Lm, or Nd. | 191 // b) Name characters other than Name-start characters must have one of the cate
gories Mc, Me, Mn, Lm, or Nd. |
| 196 // c) Characters in the compatibility area (i.e. with character code greater tha
n #xF900 and less than #xFFFE) are not allowed in XML names. | 192 // c) Characters in the compatibility area (i.e. with character code greater tha
n #xF900 and less than #xFFFE) are not allowed in XML names. |
| 197 // d) Characters which have a font or compatibility decomposition (i.e. those wi
th a "compatibility formatting tag" in field 5 of the database -- marked by fiel
d 5 beginning with a "<") are not allowed. | 193 // d) Characters which have a font or compatibility decomposition (i.e. those wi
th a "compatibility formatting tag" in field 5 of the database -- marked by fiel
d 5 beginning with a "<") are not allowed. |
| 198 // e) The following characters are treated as name-start characters rather than
name characters, because the property file classifies them as Alphabetic: [#x02B
B-#x02C1], #x0559, #x06E5, #x06E6. | 194 // e) The following characters are treated as name-start characters rather than
name characters, because the property file classifies them as Alphabetic: [#x02B
B-#x02C1], #x0559, #x06E5, #x06E6. |
| 199 // f) Characters #x20DD-#x20E0 are excluded (in accordance with Unicode, section
5.14). | 195 // f) Characters #x20DD-#x20E0 are excluded (in accordance with Unicode, section
5.14). |
| 200 // g) Character #x00B7 is classified as an extender, because the property list s
o identifies it. | 196 // g) Character #x00B7 is classified as an extender, because the property list s
o identifies it. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 , m_gotoAnchorNeededAfterStylesheetsLoad(false) | 396 , m_gotoAnchorNeededAfterStylesheetsLoad(false) |
| 401 , m_containsValidityStyleRules(false) | 397 , m_containsValidityStyleRules(false) |
| 402 , m_updateFocusAppearanceRestoresSelection(false) | 398 , m_updateFocusAppearanceRestoresSelection(false) |
| 403 , m_ignoreDestructiveWriteCount(0) | 399 , m_ignoreDestructiveWriteCount(0) |
| 404 , m_titleSetExplicitly(false) | 400 , m_titleSetExplicitly(false) |
| 405 , m_markers(adoptPtr(new DocumentMarkerController)) | 401 , m_markers(adoptPtr(new DocumentMarkerController)) |
| 406 , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFi
red) | 402 , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFi
red) |
| 407 , m_cssTarget(0) | 403 , m_cssTarget(0) |
| 408 , m_processingLoadEvent(false) | 404 , m_processingLoadEvent(false) |
| 409 , m_loadEventFinished(false) | 405 , m_loadEventFinished(false) |
| 410 , m_startTime(currentTime()) | |
| 411 , m_overMinimumLayoutThreshold(false) | |
| 412 , m_scriptRunner(ScriptRunner::create(this)) | 406 , m_scriptRunner(ScriptRunner::create(this)) |
| 413 , m_xmlVersion("1.0") | 407 , m_xmlVersion(ASCIILiteral("1.0")) |
| 414 , m_xmlStandalone(StandaloneUnspecified) | 408 , m_xmlStandalone(StandaloneUnspecified) |
| 415 , m_hasXMLDeclaration(0) | 409 , m_hasXMLDeclaration(0) |
| 416 , m_designMode(inherit) | 410 , m_designMode(inherit) |
| 417 , m_hasAnnotatedRegions(false) | 411 , m_hasAnnotatedRegions(false) |
| 418 , m_annotatedRegionsDirty(false) | 412 , m_annotatedRegionsDirty(false) |
| 419 , m_useSecureKeyboardEntryWhenActive(false) | 413 , m_useSecureKeyboardEntryWhenActive(false) |
| 420 , m_documentClasses(documentClasses) | 414 , m_documentClasses(documentClasses) |
| 421 , m_isViewSource(false) | 415 , m_isViewSource(false) |
| 422 , m_sawElementsInKnownNamespaces(false) | 416 , m_sawElementsInKnownNamespaces(false) |
| 423 , m_isSrcdocDocument(false) | 417 , m_isSrcdocDocument(false) |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 | 1161 |
| 1168 void Document::setContent(const String& content) | 1162 void Document::setContent(const String& content) |
| 1169 { | 1163 { |
| 1170 open(); | 1164 open(); |
| 1171 // FIXME: This should probably use insert(), but that's (intentionally) | 1165 // FIXME: This should probably use insert(), but that's (intentionally) |
| 1172 // not implemented for the XML parser as it's normally synonymous with | 1166 // not implemented for the XML parser as it's normally synonymous with |
| 1173 // document.write(). append() will end up yielding, but close() will | 1167 // document.write(). append() will end up yielding, but close() will |
| 1174 // pump the tokenizer syncrhonously and finish the parse. | 1168 // pump the tokenizer syncrhonously and finish the parse. |
| 1175 m_parser->pinToMainThread(); | 1169 m_parser->pinToMainThread(); |
| 1176 m_parser->append(content.impl()); | 1170 m_parser->append(content.impl()); |
| 1171 // FIXME: Append may yield for script execution. Unclear if close() |
| 1172 // will wait for the parse to complete before returning or not. |
| 1177 close(); | 1173 close(); |
| 1178 } | 1174 } |
| 1179 | 1175 |
| 1180 String Document::suggestedMIMEType() const | 1176 String Document::suggestedMIMEType() const |
| 1181 { | 1177 { |
| 1182 if (isXHTMLDocument()) | 1178 if (isXHTMLDocument()) |
| 1183 return "application/xhtml+xml"; | 1179 return "application/xhtml+xml"; |
| 1184 if (isSVGDocument()) | 1180 if (isSVGDocument()) |
| 1185 return "image/svg+xml"; | 1181 return "image/svg+xml"; |
| 1186 if (xmlStandalone()) | 1182 if (xmlStandalone()) |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2235 | 2231 |
| 2236 if (f) | 2232 if (f) |
| 2237 f->loader()->handledOnloadEvents(); | 2233 f->loader()->handledOnloadEvents(); |
| 2238 | 2234 |
| 2239 // An event handler may have removed the frame | 2235 // An event handler may have removed the frame |
| 2240 if (!frame()) { | 2236 if (!frame()) { |
| 2241 m_processingLoadEvent = false; | 2237 m_processingLoadEvent = false; |
| 2242 return; | 2238 return; |
| 2243 } | 2239 } |
| 2244 | 2240 |
| 2245 // Make sure both the initial layout and reflow happen after the onload | |
| 2246 // fires. This will improve onload scores, and other browsers do it. | |
| 2247 // If they wanna cheat, we can too. -dwh | |
| 2248 | |
| 2249 if (frame()->navigationScheduler()->locationChangePending() && elapsedTime()
< cLayoutScheduleThreshold) { | |
| 2250 // Just bail out. Before or during the onload we were shifted to another
page. | |
| 2251 // The old i-Bench suite does this. When this happens don't bother paint
ing or laying out. | |
| 2252 m_processingLoadEvent = false; | |
| 2253 view()->unscheduleRelayout(); | |
| 2254 return; | |
| 2255 } | |
| 2256 | |
| 2257 frame()->loader()->checkCallImplicitClose(); | 2241 frame()->loader()->checkCallImplicitClose(); |
| 2258 RenderObject* renderObject = renderer(); | 2242 RenderObject* renderObject = renderer(); |
| 2259 | 2243 |
| 2260 // We used to force a synchronous display and flush here. This really isn't | 2244 // We used to force a synchronous display and flush here. This really isn't |
| 2261 // necessary and can in fact be actively harmful if pages are loading at a r
ate of > 60fps | 2245 // necessary and can in fact be actively harmful if pages are loading at a r
ate of > 60fps |
| 2262 // (if your platform is syncing flushes and limiting them to 60fps). | 2246 // (if your platform is syncing flushes and limiting them to 60fps). |
| 2263 m_overMinimumLayoutThreshold = true; | |
| 2264 if (!ownerElement() || (ownerElement()->renderer() && !ownerElement()->rende
rer()->needsLayout())) { | 2247 if (!ownerElement() || (ownerElement()->renderer() && !ownerElement()->rende
rer()->needsLayout())) { |
| 2265 updateStyleIfNeeded(); | 2248 updateStyleIfNeeded(); |
| 2266 | 2249 |
| 2267 // Always do a layout after loading if needed. | 2250 // Always do a layout after loading if needed. |
| 2268 if (view() && renderObject && (!renderObject->firstChild() || renderObje
ct->needsLayout())) | 2251 if (view() && renderObject && (!renderObject->firstChild() || renderObje
ct->needsLayout())) |
| 2269 view()->layout(); | 2252 view()->layout(); |
| 2270 } | 2253 } |
| 2271 | 2254 |
| 2272 m_processingLoadEvent = false; | 2255 m_processingLoadEvent = false; |
| 2273 | 2256 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2308 // This function will only be called when FrameView thinks a layout is neede
d. | 2291 // This function will only be called when FrameView thinks a layout is neede
d. |
| 2309 // This enforces a couple extra rules. | 2292 // This enforces a couple extra rules. |
| 2310 // | 2293 // |
| 2311 // (a) Only schedule a layout once the stylesheets are loaded. | 2294 // (a) Only schedule a layout once the stylesheets are loaded. |
| 2312 // (b) Only schedule layout once we have a body element. | 2295 // (b) Only schedule layout once we have a body element. |
| 2313 | 2296 |
| 2314 return (haveStylesheetsLoaded() && body()) | 2297 return (haveStylesheetsLoaded() && body()) |
| 2315 || (documentElement() && !isHTMLHtmlElement(documentElement())); | 2298 || (documentElement() && !isHTMLHtmlElement(documentElement())); |
| 2316 } | 2299 } |
| 2317 | 2300 |
| 2318 bool Document::isLayoutTimerActive() | 2301 bool Document::parserShouldYieldAgressivelyBeforeFirstLayout() |
| 2319 { | 2302 { |
| 2320 return view() && view()->layoutPending() && !minimumLayoutDelay(); | 2303 return view() && view()->layoutPending(); |
| 2321 } | |
| 2322 | |
| 2323 int Document::minimumLayoutDelay() | |
| 2324 { | |
| 2325 if (m_overMinimumLayoutThreshold) | |
| 2326 return 0; | |
| 2327 | |
| 2328 int elapsed = elapsedTime(); | |
| 2329 m_overMinimumLayoutThreshold = elapsed > cLayoutScheduleThreshold; | |
| 2330 | |
| 2331 // We'll want to schedule the timer to fire at the minimum layout threshold. | |
| 2332 return max(0, cLayoutScheduleThreshold - elapsed); | |
| 2333 } | |
| 2334 | |
| 2335 int Document::elapsedTime() const | |
| 2336 { | |
| 2337 return static_cast<int>((currentTime() - m_startTime) * 1000); | |
| 2338 } | 2304 } |
| 2339 | 2305 |
| 2340 void Document::write(const SegmentedString& text, Document* ownerDocument) | 2306 void Document::write(const SegmentedString& text, Document* ownerDocument) |
| 2341 { | 2307 { |
| 2342 NestingLevelIncrementer nestingLevelIncrementer(m_writeRecursionDepth); | 2308 NestingLevelIncrementer nestingLevelIncrementer(m_writeRecursionDepth); |
| 2343 | 2309 |
| 2344 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > 1) && m_writeRecursionI
sTooDeep; | 2310 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > 1) && m_writeRecursionI
sTooDeep; |
| 2345 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > cMaxWriteRecursionDepth
) || m_writeRecursionIsTooDeep; | 2311 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > cMaxWriteRecursionDepth
) || m_writeRecursionIsTooDeep; |
| 2346 | 2312 |
| 2347 if (m_writeRecursionIsTooDeep) | 2313 if (m_writeRecursionIsTooDeep) |
| (...skipping 2737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5085 { | 5051 { |
| 5086 return DocumentLifecycleNotifier::create(this); | 5052 return DocumentLifecycleNotifier::create(this); |
| 5087 } | 5053 } |
| 5088 | 5054 |
| 5089 DocumentLifecycleNotifier* Document::lifecycleNotifier() | 5055 DocumentLifecycleNotifier* Document::lifecycleNotifier() |
| 5090 { | 5056 { |
| 5091 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec
ycleNotifier()); | 5057 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec
ycleNotifier()); |
| 5092 } | 5058 } |
| 5093 | 5059 |
| 5094 } // namespace WebCore | 5060 } // namespace WebCore |
| OLD | NEW |