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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 , m_hasXMLDeclaration(0) | 440 , m_hasXMLDeclaration(0) |
441 , m_designMode(inherit) | 441 , m_designMode(inherit) |
442 , m_hasAnnotatedRegions(false) | 442 , m_hasAnnotatedRegions(false) |
443 , m_annotatedRegionsDirty(false) | 443 , m_annotatedRegionsDirty(false) |
444 , m_useSecureKeyboardEntryWhenActive(false) | 444 , m_useSecureKeyboardEntryWhenActive(false) |
445 , m_documentClasses(documentClasses) | 445 , m_documentClasses(documentClasses) |
446 , m_isViewSource(false) | 446 , m_isViewSource(false) |
447 , m_sawElementsInKnownNamespaces(false) | 447 , m_sawElementsInKnownNamespaces(false) |
448 , m_isSrcdocDocument(false) | 448 , m_isSrcdocDocument(false) |
449 , m_isMobileDocument(false) | 449 , m_isMobileDocument(false) |
450 , m_mayDisplaySeamlesslyWithParent(false) | |
451 , m_renderView(0) | 450 , m_renderView(0) |
452 , m_weakFactory(this) | 451 , m_weakFactory(this) |
453 , m_contextDocument(initializer.contextDocument()) | 452 , m_contextDocument(initializer.contextDocument()) |
454 , m_hasFullscreenElementStack(false) | 453 , m_hasFullscreenElementStack(false) |
455 , m_loadEventDelayCount(0) | 454 , m_loadEventDelayCount(0) |
456 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) | 455 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) |
457 , m_didSetReferrerPolicy(false) | 456 , m_didSetReferrerPolicy(false) |
458 , m_referrerPolicy(ReferrerPolicyDefault) | 457 , m_referrerPolicy(ReferrerPolicyDefault) |
459 , m_directionSetOnDocumentElement(false) | 458 , m_directionSetOnDocumentElement(false) |
460 , m_writingModeSetOnDocumentElement(false) | 459 , m_writingModeSetOnDocumentElement(false) |
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 return 0; | 1524 return 0; |
1526 } | 1525 } |
1527 return TreeWalker::create(root, whatToShow, filter); | 1526 return TreeWalker::create(root, whatToShow, filter); |
1528 } | 1527 } |
1529 | 1528 |
1530 void Document::scheduleStyleRecalc() | 1529 void Document::scheduleStyleRecalc() |
1531 { | 1530 { |
1532 if (!isActive()) | 1531 if (!isActive()) |
1533 return; | 1532 return; |
1534 | 1533 |
1535 if (shouldDisplaySeamlesslyWithParent()) { | |
1536 // When we're seamless, our parent document manages our style recalcs. | |
1537 ownerElement()->setNeedsStyleRecalc(); | |
1538 ownerElement()->document().scheduleStyleRecalc(); | |
1539 return; | |
1540 } | |
1541 | |
1542 if (m_styleRecalcTimer.isActive() || !shouldScheduleLayout()) | 1534 if (m_styleRecalcTimer.isActive() || !shouldScheduleLayout()) |
1543 return; | 1535 return; |
1544 | 1536 |
1545 ASSERT(needsStyleRecalc() || childNeedsStyleRecalc() || childNeedsDistributi
onRecalc() || !m_useElementsNeedingUpdate.isEmpty()); | 1537 ASSERT(needsStyleRecalc() || childNeedsStyleRecalc() || childNeedsDistributi
onRecalc() || !m_useElementsNeedingUpdate.isEmpty()); |
1546 | 1538 |
1547 m_styleRecalcTimer.startOneShot(0); | 1539 m_styleRecalcTimer.startOneShot(0); |
1548 | 1540 |
1549 InspectorInstrumentation::didScheduleStyleRecalculation(this); | 1541 InspectorInstrumentation::didScheduleStyleRecalculation(this); |
1550 } | 1542 } |
1551 | 1543 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 void Document::setStyleDependentState(RenderStyle* documentStyle) | 1583 void Document::setStyleDependentState(RenderStyle* documentStyle) |
1592 { | 1584 { |
1593 const Pagination& pagination = view()->pagination(); | 1585 const Pagination& pagination = view()->pagination(); |
1594 if (pagination.mode != Pagination::Unpaginated) { | 1586 if (pagination.mode != Pagination::Unpaginated) { |
1595 Pagination::setStylesForPaginationMode(pagination.mode, documentStyle); | 1587 Pagination::setStylesForPaginationMode(pagination.mode, documentStyle); |
1596 documentStyle->setColumnGap(pagination.gap); | 1588 documentStyle->setColumnGap(pagination.gap); |
1597 if (renderView()->hasColumns()) | 1589 if (renderView()->hasColumns()) |
1598 renderView()->updateColumnInfoFromStyle(documentStyle); | 1590 renderView()->updateColumnInfoFromStyle(documentStyle); |
1599 } | 1591 } |
1600 | 1592 |
1601 // Seamless iframes want to inherit their font from their parent iframe, so
early return before setting the font. | |
1602 if (shouldDisplaySeamlesslyWithParent()) | |
1603 return; | |
1604 | |
1605 FontBuilder fontBuilder; | 1593 FontBuilder fontBuilder; |
1606 fontBuilder.initForStyleResolve(*this, documentStyle, isSVGDocument()); | 1594 fontBuilder.initForStyleResolve(*this, documentStyle, isSVGDocument()); |
1607 RefPtr<CSSFontSelector> selector = m_styleEngine->fontSelector(); | 1595 RefPtr<CSSFontSelector> selector = m_styleEngine->fontSelector(); |
1608 fontBuilder.createFontForDocument(selector, documentStyle); | 1596 fontBuilder.createFontForDocument(selector, documentStyle); |
1609 } | 1597 } |
1610 | 1598 |
1611 void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change) | 1599 void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change) |
1612 { | 1600 { |
1613 ASSERT(inStyleRecalc()); | 1601 ASSERT(inStyleRecalc()); |
1614 ASSERT(documentElement()); | 1602 ASSERT(documentElement()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1671 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc
ulateStyle(this); | 1659 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc
ulateStyle(this); |
1672 | 1660 |
1673 updateDistributionIfNeeded(); | 1661 updateDistributionIfNeeded(); |
1674 updateUseShadowTrees(); | 1662 updateUseShadowTrees(); |
1675 | 1663 |
1676 if (m_evaluateMediaQueriesOnStyleRecalc) { | 1664 if (m_evaluateMediaQueriesOnStyleRecalc) { |
1677 m_evaluateMediaQueriesOnStyleRecalc = false; | 1665 m_evaluateMediaQueriesOnStyleRecalc = false; |
1678 evaluateMediaQueryList(); | 1666 evaluateMediaQueryList(); |
1679 } | 1667 } |
1680 | 1668 |
1681 // FIXME: We should update style on our ancestor chain before proceeding (es
pecially for seamless), | 1669 // FIXME: We should update style on our ancestor chain before proceeding |
1682 // however doing so currently causes several tests to crash, as Frame::setDo
cument calls Document::attach | 1670 // however doing so currently causes several tests to crash, as Frame::setDo
cument calls Document::attach |
1683 // before setting the DOMWindow on the Frame, or the SecurityOrigin on the d
ocument. The attach, in turn | 1671 // before setting the DOMWindow on the Frame, or the SecurityOrigin on the d
ocument. The attach, in turn |
1684 // resolves style (here) and then when we resolve style on the parent chain,
we may end up | 1672 // resolves style (here) and then when we resolve style on the parent chain,
we may end up |
1685 // re-attaching our containing iframe, which when asked HTMLFrameElementBase
::isURLAllowed | 1673 // re-attaching our containing iframe, which when asked HTMLFrameElementBase
::isURLAllowed |
1686 // hits a null-dereference due to security code always assuming the document
has a SecurityOrigin. | 1674 // hits a null-dereference due to security code always assuming the document
has a SecurityOrigin. |
1687 | 1675 |
1688 if (m_elemSheet && m_elemSheet->contents()->usesRemUnits()) | 1676 if (m_elemSheet && m_elemSheet->contents()->usesRemUnits()) |
1689 m_styleEngine->setUsesRemUnit(true); | 1677 m_styleEngine->setUsesRemUnit(true); |
1690 | 1678 |
1691 { | 1679 { |
1692 PostAttachCallbacks::SuspendScope suspendPostAttachCallbacks; | 1680 PostAttachCallbacks::SuspendScope suspendPostAttachCallbacks; |
1693 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 1681 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
1694 TemporaryChange<bool> changeInStyleRecalc(m_inStyleRecalc, true); | 1682 TemporaryChange<bool> changeInStyleRecalc(m_inStyleRecalc, true); |
1695 | 1683 |
1696 if (styleChangeType() >= SubtreeStyleChange) | 1684 if (styleChangeType() >= SubtreeStyleChange) |
1697 change = Force; | 1685 change = Force; |
1698 | 1686 |
1699 // FIXME: Cannot access the ensureStyleResolver() before calling styleFo
rDocument below because | 1687 // FIXME: Cannot access the ensureStyleResolver() before calling styleFo
rDocument below because |
1700 // apparently the StyleResolver's constructor has side effects. We shoul
d fix it. | 1688 // apparently the StyleResolver's constructor has side effects. We shoul
d fix it. |
1701 // See printing/setPrinting.html, printing/width-overflow.html though th
ey only fail on | 1689 // See printing/setPrinting.html, printing/width-overflow.html though th
ey only fail on |
1702 // mac when accessing the resolver by what appears to be a viewport size
difference. | 1690 // mac when accessing the resolver by what appears to be a viewport size
difference. |
1703 | 1691 |
1704 if (change == Force || (change >= Inherit && shouldDisplaySeamlesslyWith
Parent())) { | 1692 if (change == Force) { |
1705 m_hasNodesWithPlaceholderStyle = false; | 1693 m_hasNodesWithPlaceholderStyle = false; |
1706 RefPtr<RenderStyle> documentStyle = StyleResolver::styleForDocument(
*this, m_styleEngine->fontSelector()); | 1694 RefPtr<RenderStyle> documentStyle = StyleResolver::styleForDocument(
*this, m_styleEngine->fontSelector()); |
1707 StyleRecalcChange localChange = RenderStyle::compare(documentStyle.g
et(), renderView()->style()); | 1695 StyleRecalcChange localChange = RenderStyle::compare(documentStyle.g
et(), renderView()->style()); |
1708 if (localChange != NoChange) | 1696 if (localChange != NoChange) |
1709 renderView()->setStyle(documentStyle.release()); | 1697 renderView()->setStyle(documentStyle.release()); |
1710 } | 1698 } |
1711 | 1699 |
1712 clearNeedsStyleRecalc(); | 1700 clearNeedsStyleRecalc(); |
1713 | 1701 |
1714 // Uncomment to enable printing of statistics about style sharing and th
e matched property cache. | 1702 // Uncomment to enable printing of statistics about style sharing and th
e matched property cache. |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2230 | 2218 |
2231 PassRefPtr<DocumentParser> Document::implicitOpen() | 2219 PassRefPtr<DocumentParser> Document::implicitOpen() |
2232 { | 2220 { |
2233 cancelParsing(); | 2221 cancelParsing(); |
2234 | 2222 |
2235 removeChildren(); | 2223 removeChildren(); |
2236 ASSERT(!m_focusedElement); | 2224 ASSERT(!m_focusedElement); |
2237 | 2225 |
2238 setCompatibilityMode(NoQuirksMode); | 2226 setCompatibilityMode(NoQuirksMode); |
2239 | 2227 |
2240 // Documents rendered seamlessly should start out requiring a stylesheet | |
2241 // collection update in order to ensure they inherit all the relevant data | |
2242 // from their parent. | |
2243 if (shouldDisplaySeamlesslyWithParent()) | |
2244 styleResolverChanged(RecalcStyleDeferred); | |
2245 | |
2246 m_parser = createParser(); | 2228 m_parser = createParser(); |
2247 setParsing(true); | 2229 setParsing(true); |
2248 setReadyState(Loading); | 2230 setReadyState(Loading); |
2249 | 2231 |
2250 return m_parser; | 2232 return m_parser; |
2251 } | 2233 } |
2252 | 2234 |
2253 HTMLElement* Document::body() const | 2235 HTMLElement* Document::body() const |
2254 { | 2236 { |
2255 if (!documentElement()) | 2237 if (!documentElement()) |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2806 | 2788 |
2807 while (ancestorFrame) { | 2789 while (ancestorFrame) { |
2808 if (!ancestorFrame->document()->securityOrigin()->canAccess(securityOrig
in())) | 2790 if (!ancestorFrame->document()->securityOrigin()->canAccess(securityOrig
in())) |
2809 return currentFrame; | 2791 return currentFrame; |
2810 currentFrame = ancestorFrame; | 2792 currentFrame = ancestorFrame; |
2811 ancestorFrame = ancestorFrame->tree().parent(); | 2793 ancestorFrame = ancestorFrame->tree().parent(); |
2812 } | 2794 } |
2813 return 0; | 2795 return 0; |
2814 } | 2796 } |
2815 | 2797 |
2816 | |
2817 void Document::seamlessParentUpdatedStylesheets() | |
2818 { | |
2819 m_styleEngine->didModifySeamlessParentStyleSheet(); | |
2820 styleResolverChanged(RecalcStyleImmediately); | |
2821 } | |
2822 | |
2823 void Document::didRemoveAllPendingStylesheet() | 2798 void Document::didRemoveAllPendingStylesheet() |
2824 { | 2799 { |
2825 m_needsNotifyRemoveAllPendingStylesheet = false; | 2800 m_needsNotifyRemoveAllPendingStylesheet = false; |
2826 | 2801 |
2827 styleResolverChanged(RecalcStyleDeferred, AnalyzedStyleUpdate); | 2802 styleResolverChanged(RecalcStyleDeferred, AnalyzedStyleUpdate); |
2828 executeScriptsWaitingForResourcesIfNeeded(); | 2803 executeScriptsWaitingForResourcesIfNeeded(); |
2829 | 2804 |
2830 if (m_gotoAnchorNeededAfterStylesheetsLoad && view()) | 2805 if (m_gotoAnchorNeededAfterStylesheetsLoad && view()) |
2831 view()->scrollToFragment(m_url); | 2806 view()->scrollToFragment(m_url); |
2832 } | 2807 } |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3253 if (!change.needsStyleRecalc()) | 3228 if (!change.needsStyleRecalc()) |
3254 return; | 3229 return; |
3255 | 3230 |
3256 m_evaluateMediaQueriesOnStyleRecalc = true; | 3231 m_evaluateMediaQueriesOnStyleRecalc = true; |
3257 setNeedsStyleRecalc(); | 3232 setNeedsStyleRecalc(); |
3258 | 3233 |
3259 if (updateTime == RecalcStyleImmediately) | 3234 if (updateTime == RecalcStyleImmediately) |
3260 updateStyleIfNeeded(); | 3235 updateStyleIfNeeded(); |
3261 } | 3236 } |
3262 | 3237 |
3263 void Document::notifySeamlessChildDocumentsOfStylesheetUpdate() const | |
3264 { | |
3265 // If we're not in a frame yet any potential child documents won't have a St
yleResolver to update. | |
3266 if (!frame()) | |
3267 return; | |
3268 | |
3269 // Seamless child frames are expected to notify their seamless children recu
rsively, so we only do direct children. | |
3270 for (Frame* child = frame()->tree().firstChild(); child; child = child->tree
().nextSibling()) { | |
3271 Document* childDocument = child->document(); | |
3272 if (childDocument->shouldDisplaySeamlesslyWithParent()) { | |
3273 ASSERT(childDocument->seamlessParentIFrame()->document() == this); | |
3274 childDocument->seamlessParentUpdatedStylesheets(); | |
3275 } | |
3276 } | |
3277 } | |
3278 | |
3279 void Document::setHoverNode(PassRefPtr<Node> newHoverNode) | 3238 void Document::setHoverNode(PassRefPtr<Node> newHoverNode) |
3280 { | 3239 { |
3281 m_hoverNode = newHoverNode; | 3240 m_hoverNode = newHoverNode; |
3282 } | 3241 } |
3283 | 3242 |
3284 void Document::setActiveHoverElement(PassRefPtr<Element> newActiveElement) | 3243 void Document::setActiveHoverElement(PassRefPtr<Element> newActiveElement) |
3285 { | 3244 { |
3286 if (!newActiveElement) { | 3245 if (!newActiveElement) { |
3287 m_activeHoverElement.clear(); | 3246 m_activeHoverElement.clear(); |
3288 return; | 3247 return; |
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4526 securityOrigin()->enforceFilePathSeparation(); | 4485 securityOrigin()->enforceFilePathSeparation(); |
4527 } | 4486 } |
4528 } | 4487 } |
4529 } | 4488 } |
4530 | 4489 |
4531 if (initializer.shouldTreatURLAsSrcdocDocument()) { | 4490 if (initializer.shouldTreatURLAsSrcdocDocument()) { |
4532 m_isSrcdocDocument = true; | 4491 m_isSrcdocDocument = true; |
4533 setBaseURLOverride(initializer.parentBaseURL()); | 4492 setBaseURLOverride(initializer.parentBaseURL()); |
4534 } | 4493 } |
4535 | 4494 |
4536 // FIXME: What happens if we inherit the security origin? This check may nee
d to be later. | |
4537 // <iframe seamless src="about:blank"> likely won't work as-is. | |
4538 m_mayDisplaySeamlesslyWithParent = initializer.isSeamlessAllowedFor(this); | |
4539 | |
4540 if (!shouldInheritSecurityOriginFromOwner(m_url)) | 4495 if (!shouldInheritSecurityOriginFromOwner(m_url)) |
4541 return; | 4496 return; |
4542 | 4497 |
4543 // If we do not obtain a meaningful origin from the URL, then we try to | 4498 // If we do not obtain a meaningful origin from the URL, then we try to |
4544 // find one via the frame hierarchy. | 4499 // find one via the frame hierarchy. |
4545 | 4500 |
4546 if (!initializer.owner()) { | 4501 if (!initializer.owner()) { |
4547 didFailToInitializeSecurityOrigin(); | 4502 didFailToInitializeSecurityOrigin(); |
4548 return; | 4503 return; |
4549 } | 4504 } |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4965 if (m_touchEventTargets->isEmpty() && parentDocument()) | 4920 if (m_touchEventTargets->isEmpty() && parentDocument()) |
4966 parentDocument()->didRemoveEventTargetNode(this); | 4921 parentDocument()->didRemoveEventTargetNode(this); |
4967 } | 4922 } |
4968 } | 4923 } |
4969 | 4924 |
4970 void Document::resetLastHandledUserGestureTimestamp() | 4925 void Document::resetLastHandledUserGestureTimestamp() |
4971 { | 4926 { |
4972 m_lastHandledUserGestureTimestamp = currentTime(); | 4927 m_lastHandledUserGestureTimestamp = currentTime(); |
4973 } | 4928 } |
4974 | 4929 |
4975 HTMLIFrameElement* Document::seamlessParentIFrame() const | |
4976 { | |
4977 if (!shouldDisplaySeamlesslyWithParent()) | |
4978 return 0; | |
4979 | |
4980 return toHTMLIFrameElement(this->ownerElement()); | |
4981 } | |
4982 | |
4983 bool Document::shouldDisplaySeamlesslyWithParent() const | |
4984 { | |
4985 if (!RuntimeEnabledFeatures::seamlessIFramesEnabled()) | |
4986 return false; | |
4987 HTMLFrameOwnerElement* ownerElement = this->ownerElement(); | |
4988 if (!ownerElement) | |
4989 return false; | |
4990 return m_mayDisplaySeamlesslyWithParent && ownerElement->hasTagName(iframeTa
g) && ownerElement->fastHasAttribute(seamlessAttr); | |
4991 } | |
4992 | |
4993 DocumentLoader* Document::loader() const | 4930 DocumentLoader* Document::loader() const |
4994 { | 4931 { |
4995 if (!m_frame) | 4932 if (!m_frame) |
4996 return 0; | 4933 return 0; |
4997 | 4934 |
4998 DocumentLoader* loader = m_frame->loader().documentLoader(); | 4935 DocumentLoader* loader = m_frame->loader().documentLoader(); |
4999 if (!loader) | 4936 if (!loader) |
5000 return 0; | 4937 return 0; |
5001 | 4938 |
5002 if (m_frame->document() != this) | 4939 if (m_frame->document() != this) |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5364 if (!page->focusController().isActive() || !page->focusController().isFocuse
d()) | 5301 if (!page->focusController().isActive() || !page->focusController().isFocuse
d()) |
5365 return false; | 5302 return false; |
5366 if (Frame* focusedFrame = page->focusController().focusedFrame()) { | 5303 if (Frame* focusedFrame = page->focusController().focusedFrame()) { |
5367 if (focusedFrame->tree().isDescendantOf(frame())) | 5304 if (focusedFrame->tree().isDescendantOf(frame())) |
5368 return true; | 5305 return true; |
5369 } | 5306 } |
5370 return false; | 5307 return false; |
5371 } | 5308 } |
5372 | 5309 |
5373 } // namespace WebCore | 5310 } // namespace WebCore |
OLD | NEW |