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 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 } | 1616 } |
1617 Node* root = node; | 1617 Node* root = node; |
1618 while (Node* host = root->shadowHost()) | 1618 while (Node* host = root->shadowHost()) |
1619 root = host; | 1619 root = host; |
1620 while (Node* ancestor = root->parentOrShadowHostNode()) | 1620 while (Node* ancestor = root->parentOrShadowHostNode()) |
1621 root = ancestor; | 1621 root = ancestor; |
1622 if (root->childNeedsDistributionRecalc()) | 1622 if (root->childNeedsDistributionRecalc()) |
1623 root->recalcDistribution(); | 1623 root->recalcDistribution(); |
1624 } | 1624 } |
1625 | 1625 |
1626 void Document::setStyleDependentState(RenderStyle* documentStyle) | 1626 void Document::setupFontBuilder(RenderStyle* documentStyle) |
1627 { | 1627 { |
1628 const Pagination& pagination = view()->pagination(); | |
1629 if (pagination.mode != Pagination::Unpaginated) { | |
1630 Pagination::setStylesForPaginationMode(pagination.mode, documentStyle); | |
1631 documentStyle->setColumnGap(pagination.gap); | |
1632 if (renderView()->hasColumns()) | |
1633 renderView()->updateColumnInfoFromStyle(documentStyle); | |
1634 } | |
1635 | |
1636 FontBuilder fontBuilder; | 1628 FontBuilder fontBuilder; |
1637 fontBuilder.initForStyleResolve(*this, documentStyle, isSVGDocument()); | 1629 fontBuilder.initForStyleResolve(*this, documentStyle, isSVGDocument()); |
1638 RefPtr<CSSFontSelector> selector = m_styleEngine->fontSelector(); | 1630 RefPtr<CSSFontSelector> selector = m_styleEngine->fontSelector(); |
1639 fontBuilder.createFontForDocument(selector, documentStyle); | 1631 fontBuilder.createFontForDocument(selector, documentStyle); |
1640 } | 1632 } |
1641 | 1633 |
1642 void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change) | 1634 void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change) |
1643 { | 1635 { |
1644 ASSERT(inStyleRecalc()); | 1636 ASSERT(inStyleRecalc()); |
1645 ASSERT(documentElement()); | 1637 ASSERT(documentElement()); |
1646 | 1638 |
1647 RefPtr<RenderStyle> documentElementStyle = documentElement()->renderStyle(); | 1639 RefPtr<RenderStyle> documentElementStyle = documentElement()->renderStyle(); |
1648 if (!documentElementStyle || documentElement()->needsStyleRecalc() || change
== Force) | 1640 if (!documentElementStyle || documentElement()->needsStyleRecalc() || change
== Force) |
1649 documentElementStyle = ensureStyleResolver().styleForElement(documentEle
ment()); | 1641 documentElementStyle = ensureStyleResolver().styleForElement(documentEle
ment()); |
1650 | 1642 |
1651 WritingMode rootWritingMode = documentElementStyle->writingMode(); | 1643 WritingMode rootWritingMode = documentElementStyle->writingMode(); |
1652 TextDirection rootDirection = documentElementStyle->direction(); | 1644 TextDirection rootDirection = documentElementStyle->direction(); |
| 1645 |
1653 HTMLElement* body = this->body(); | 1646 HTMLElement* body = this->body(); |
1654 | 1647 RefPtr<RenderStyle> bodyStyle; |
1655 if (body) { | 1648 if (body) { |
1656 RefPtr<RenderStyle> bodyStyle = body->renderStyle(); | 1649 bodyStyle = body->renderStyle(); |
1657 if (!bodyStyle || body->needsStyleRecalc() || documentElement()->needsSt
yleRecalc() || change == Force) | 1650 if (!bodyStyle || body->needsStyleRecalc() || documentElement()->needsSt
yleRecalc() || change == Force) |
1658 bodyStyle = ensureStyleResolver().styleForElement(body, documentElem
entStyle.get()); | 1651 bodyStyle = ensureStyleResolver().styleForElement(body, documentElem
entStyle.get()); |
1659 if (!writingModeSetOnDocumentElement()) | 1652 if (!writingModeSetOnDocumentElement()) |
1660 rootWritingMode = bodyStyle->writingMode(); | 1653 rootWritingMode = bodyStyle->writingMode(); |
1661 if (!directionSetOnDocumentElement()) | 1654 if (!directionSetOnDocumentElement()) |
1662 rootDirection = bodyStyle->direction(); | 1655 rootDirection = bodyStyle->direction(); |
1663 } | 1656 } |
1664 | 1657 |
| 1658 RefPtr<RenderStyle> overflowStyle; |
| 1659 if (Element* element = viewportDefiningElement(documentElementStyle.get()))
{ |
| 1660 if (element == body) { |
| 1661 overflowStyle = bodyStyle; |
| 1662 } else { |
| 1663 ASSERT(element == documentElement()); |
| 1664 overflowStyle = documentElementStyle; |
| 1665 } |
| 1666 } |
| 1667 |
1665 // Resolved rem units are stored in the matched properties cache so we need
to make sure to | 1668 // Resolved rem units are stored in the matched properties cache so we need
to make sure to |
1666 // invalidate the cache if the documentElement needed to reattach or the fon
t size changed | 1669 // invalidate the cache if the documentElement needed to reattach or the fon
t size changed |
1667 // and then trigger a full document recalc. We also need to clear it here si
nce the | 1670 // and then trigger a full document recalc. We also need to clear it here si
nce the |
1668 // call to styleForElement on the body above can cache bad values for rem un
its if the | 1671 // call to styleForElement on the body above can cache bad values for rem un
its if the |
1669 // documentElement's style was dirty. We could keep track of which elements
depend on | 1672 // documentElement's style was dirty. We could keep track of which elements
depend on |
1670 // rem units like we do for viewport styles, but we assume root font size ch
anges are | 1673 // rem units like we do for viewport styles, but we assume root font size ch
anges are |
1671 // rare and just invalidate the cache for now. | 1674 // rare and just invalidate the cache for now. |
1672 if (styleEngine()->usesRemUnits() && (documentElement()->needsAttach() || do
cumentElement()->computedStyle()->fontSize() != documentElementStyle->fontSize()
)) { | 1675 if (styleEngine()->usesRemUnits() && (documentElement()->needsAttach() || do
cumentElement()->computedStyle()->fontSize() != documentElementStyle->fontSize()
)) { |
1673 ensureStyleResolver().invalidateMatchedPropertiesCache(); | 1676 ensureStyleResolver().invalidateMatchedPropertiesCache(); |
1674 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange); | 1677 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange); |
1675 } | 1678 } |
1676 | 1679 |
1677 RefPtr<RenderStyle> documentStyle = renderView()->style(); | 1680 RefPtr<RenderStyle> documentStyle = renderView()->style(); |
1678 if (documentStyle->writingMode() != rootWritingMode || documentStyle->direct
ion() != rootDirection) { | 1681 if (documentStyle->writingMode() != rootWritingMode |
| 1682 || documentStyle->direction() != rootDirection |
| 1683 || (overflowStyle && (documentStyle->overflowX() != overflowStyle->overf
lowX() || documentStyle->overflowY() != overflowStyle->overflowY()))) { |
1679 RefPtr<RenderStyle> newStyle = RenderStyle::clone(documentStyle.get()); | 1684 RefPtr<RenderStyle> newStyle = RenderStyle::clone(documentStyle.get()); |
1680 newStyle->setWritingMode(rootWritingMode); | 1685 newStyle->setWritingMode(rootWritingMode); |
1681 newStyle->setDirection(rootDirection); | 1686 newStyle->setDirection(rootDirection); |
| 1687 EOverflow overflowX = OAUTO; |
| 1688 EOverflow overflowY = OAUTO; |
| 1689 if (overflowStyle) { |
| 1690 overflowX = overflowStyle->overflowX(); |
| 1691 overflowY = overflowStyle->overflowY(); |
| 1692 // Visible overflow on the viewport is meaningless, and the spec say
s to treat it as 'auto': |
| 1693 if (overflowX == OVISIBLE) |
| 1694 overflowX = OAUTO; |
| 1695 if (overflowY == OVISIBLE) |
| 1696 overflowY = OAUTO; |
| 1697 |
| 1698 // Column-gap is (ab)used by the current paged overflow implementati
on (in lack of other |
| 1699 // ways to specify gaps between pages), so we have to propagate it t
oo. |
| 1700 newStyle->setColumnGap(overflowStyle->columnGap()); |
| 1701 } |
| 1702 newStyle->setOverflowX(overflowX); |
| 1703 newStyle->setOverflowY(overflowY); |
1682 renderView()->setStyle(newStyle); | 1704 renderView()->setStyle(newStyle); |
1683 setStyleDependentState(newStyle.get()); | 1705 setupFontBuilder(newStyle.get()); |
1684 } | 1706 } |
1685 | 1707 |
1686 if (body) { | 1708 if (body) { |
1687 if (RenderStyle* style = body->renderStyle()) { | 1709 if (RenderStyle* style = body->renderStyle()) { |
1688 if (style->direction() != rootDirection || style->writingMode() != r
ootWritingMode) | 1710 if (style->direction() != rootDirection || style->writingMode() != r
ootWritingMode) |
1689 body->setNeedsStyleRecalc(SubtreeStyleChange); | 1711 body->setNeedsStyleRecalc(SubtreeStyleChange); |
1690 } | 1712 } |
1691 } | 1713 } |
1692 | 1714 |
1693 if (RenderStyle* style = documentElement()->renderStyle()) { | 1715 if (RenderStyle* style = documentElement()->renderStyle()) { |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2349 if (!de) | 2371 if (!de) |
2350 return 0; | 2372 return 0; |
2351 | 2373 |
2352 for (Node* node = de->firstChild(); node; node = node->nextSibling()) { | 2374 for (Node* node = de->firstChild(); node; node = node->nextSibling()) { |
2353 if (node->hasTagName(headTag)) | 2375 if (node->hasTagName(headTag)) |
2354 return toHTMLHeadElement(node); | 2376 return toHTMLHeadElement(node); |
2355 } | 2377 } |
2356 return 0; | 2378 return 0; |
2357 } | 2379 } |
2358 | 2380 |
| 2381 Element* Document::viewportDefiningElement(RenderStyle* rootStyle) const |
| 2382 { |
| 2383 // If a BODY element sets non-visible overflow, it is to be propagated to th
e viewport, as long |
| 2384 // as the following conditions are all met: |
| 2385 // (1) The root element is HTML. |
| 2386 // (2) It is the primary BODY element (we only assert for this, expecting ca
llers to behave). |
| 2387 // (3) The root element has visible overflow. |
| 2388 // Otherwise it's the root element's properties that are to be propagated. |
| 2389 Element* rootElement = documentElement(); |
| 2390 Element* bodyElement = body(); |
| 2391 if (!rootElement) |
| 2392 return 0; |
| 2393 if (!rootStyle) { |
| 2394 rootStyle = rootElement->renderStyle(); |
| 2395 if (!rootStyle) |
| 2396 return 0; |
| 2397 } |
| 2398 if (bodyElement && rootStyle->isOverflowVisible() && rootElement->hasTagName
(htmlTag)) |
| 2399 return bodyElement; |
| 2400 return rootElement; |
| 2401 } |
| 2402 |
2359 void Document::close() | 2403 void Document::close() |
2360 { | 2404 { |
2361 // FIXME: We should follow the specification more closely: | 2405 // FIXME: We should follow the specification more closely: |
2362 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-cl
ose | 2406 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-cl
ose |
2363 | 2407 |
2364 if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedBy
Script() || !scriptableDocumentParser()->isParsing()) | 2408 if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedBy
Script() || !scriptableDocumentParser()->isParsing()) |
2365 return; | 2409 return; |
2366 | 2410 |
2367 explicitClose(); | 2411 explicitClose(); |
2368 } | 2412 } |
(...skipping 3035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5404 void Document::defaultEventHandler(Event* event) | 5448 void Document::defaultEventHandler(Event* event) |
5405 { | 5449 { |
5406 if (frame() && frame()->remotePlatformLayer()) { | 5450 if (frame() && frame()->remotePlatformLayer()) { |
5407 frame()->chromeClient().forwardInputEvent(this, event); | 5451 frame()->chromeClient().forwardInputEvent(this, event); |
5408 return; | 5452 return; |
5409 } | 5453 } |
5410 Node::defaultEventHandler(event); | 5454 Node::defaultEventHandler(event); |
5411 } | 5455 } |
5412 | 5456 |
5413 } // namespace WebCore | 5457 } // namespace WebCore |
OLD | NEW |