| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2011 Google Inc. All Rights Reserved. |
| 3 * Copyright (C) 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "sky/engine/config.h" | 27 #include "sky/engine/config.h" |
| 28 #include "sky/engine/core/dom/TreeScope.h" | 28 #include "sky/engine/core/dom/TreeScope.h" |
| 29 | 29 |
| 30 #include "gen/sky/core/HTMLNames.h" | 30 #include "gen/sky/core/HTMLNames.h" |
| 31 #include "sky/engine/core/css/resolver/ScopedStyleResolver.h" | 31 #include "sky/engine/core/css/resolver/ScopedStyleResolver.h" |
| 32 #include "sky/engine/core/dom/ContainerNode.h" | 32 #include "sky/engine/core/dom/ContainerNode.h" |
| 33 #include "sky/engine/core/dom/Document.h" | 33 #include "sky/engine/core/dom/Document.h" |
| 34 #include "sky/engine/core/dom/Element.h" | 34 #include "sky/engine/core/dom/Element.h" |
| 35 #include "sky/engine/core/dom/ElementTraversal.h" | 35 #include "sky/engine/core/dom/ElementTraversal.h" |
| 36 #include "sky/engine/core/dom/NodeRenderStyle.h" | 36 #include "sky/engine/core/dom/NodeRenderStyle.h" |
| 37 #include "sky/engine/core/dom/StyleSheetCollection.h" |
| 37 #include "sky/engine/core/dom/TreeScopeAdopter.h" | 38 #include "sky/engine/core/dom/TreeScopeAdopter.h" |
| 38 #include "sky/engine/core/dom/shadow/ElementShadow.h" | 39 #include "sky/engine/core/dom/shadow/ElementShadow.h" |
| 39 #include "sky/engine/core/dom/shadow/ShadowRoot.h" | 40 #include "sky/engine/core/dom/shadow/ShadowRoot.h" |
| 40 #include "sky/engine/core/editing/DOMSelection.h" | 41 #include "sky/engine/core/editing/DOMSelection.h" |
| 41 #include "sky/engine/core/events/EventPath.h" | 42 #include "sky/engine/core/events/EventPath.h" |
| 42 #include "sky/engine/core/frame/FrameView.h" | 43 #include "sky/engine/core/frame/FrameView.h" |
| 43 #include "sky/engine/core/frame/LocalFrame.h" | 44 #include "sky/engine/core/frame/LocalFrame.h" |
| 44 #include "sky/engine/core/html/HTMLAnchorElement.h" | 45 #include "sky/engine/core/html/HTMLAnchorElement.h" |
| 45 #include "sky/engine/core/page/FocusController.h" | 46 #include "sky/engine/core/page/FocusController.h" |
| 46 #include "sky/engine/core/page/Page.h" | 47 #include "sky/engine/core/page/Page.h" |
| 47 #include "sky/engine/core/rendering/HitTestResult.h" | 48 #include "sky/engine/core/rendering/HitTestResult.h" |
| 48 #include "sky/engine/core/rendering/RenderView.h" | 49 #include "sky/engine/core/rendering/RenderView.h" |
| 49 #include "sky/engine/wtf/Vector.h" | 50 #include "sky/engine/wtf/Vector.h" |
| 50 | 51 |
| 51 namespace blink { | 52 namespace blink { |
| 52 | 53 |
| 53 TreeScope::TreeScope(ContainerNode& rootNode, Document& document) | 54 TreeScope::TreeScope(ContainerNode& rootNode, Document& document) |
| 54 : m_rootNode(&rootNode) | 55 : m_rootNode(&rootNode) |
| 55 , m_document(&document) | 56 , m_document(&document) |
| 56 , m_parentTreeScope(&document) | 57 , m_parentTreeScope(&document) |
| 57 , m_scopedStyleResolver(ScopedStyleResolver::create(*this)) | 58 , m_scopedStyleResolver(ScopedStyleResolver::create(*this)) |
| 59 , m_styleSheets(StyleSheetCollection::create(*this)) |
| 58 , m_guardRefCount(0) | 60 , m_guardRefCount(0) |
| 59 { | 61 { |
| 60 ASSERT(rootNode != document); | 62 ASSERT(rootNode != document); |
| 61 #if !ENABLE(OILPAN) | |
| 62 m_parentTreeScope->guardRef(); | 63 m_parentTreeScope->guardRef(); |
| 63 #endif | |
| 64 m_rootNode->setTreeScope(this); | 64 m_rootNode->setTreeScope(this); |
| 65 } | 65 } |
| 66 | 66 |
| 67 TreeScope::TreeScope(Document& document) | 67 TreeScope::TreeScope(Document& document) |
| 68 : m_rootNode(document) | 68 : m_rootNode(document) |
| 69 , m_document(&document) | 69 , m_document(&document) |
| 70 , m_parentTreeScope(nullptr) | 70 , m_parentTreeScope(nullptr) |
| 71 , m_scopedStyleResolver(ScopedStyleResolver::create(*this)) | 71 , m_scopedStyleResolver(ScopedStyleResolver::create(*this)) |
| 72 , m_styleSheets(StyleSheetCollection::create(*this)) |
| 72 , m_guardRefCount(0) | 73 , m_guardRefCount(0) |
| 73 { | 74 { |
| 74 m_rootNode->setTreeScope(this); | 75 m_rootNode->setTreeScope(this); |
| 75 } | 76 } |
| 76 | 77 |
| 77 TreeScope::~TreeScope() | 78 TreeScope::~TreeScope() |
| 78 { | 79 { |
| 79 ASSERT(!m_guardRefCount); | 80 ASSERT(!m_guardRefCount); |
| 80 m_rootNode->setTreeScope(0); | 81 m_rootNode->setTreeScope(0); |
| 81 | 82 |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 RenderStyle* style = element->renderStyle(); | 401 RenderStyle* style = element->renderStyle(); |
| 401 if (style && style->hasViewportUnits()) | 402 if (style && style->hasViewportUnits()) |
| 402 element->setNeedsStyleRecalc(LocalStyleChange); | 403 element->setNeedsStyleRecalc(LocalStyleChange); |
| 403 } | 404 } |
| 404 } | 405 } |
| 405 | 406 |
| 406 bool TreeScope::hasSameStyles(TreeScope& other) | 407 bool TreeScope::hasSameStyles(TreeScope& other) |
| 407 { | 408 { |
| 408 if (this == &other) | 409 if (this == &other) |
| 409 return true; | 410 return true; |
| 410 const Vector<RefPtr<blink::CSSStyleSheet> >& list = document().styleEngine()
->activeAuthorStyleSheetsFor(*this); | 411 const Vector<RefPtr<blink::CSSStyleSheet> >& list = styleSheets().activeAuth
orStyleSheets(); |
| 411 const Vector<RefPtr<blink::CSSStyleSheet> >& otherList = document().styleEng
ine()->activeAuthorStyleSheetsFor(other); | 412 const Vector<RefPtr<blink::CSSStyleSheet> >& otherList = other.styleSheets()
.activeAuthorStyleSheets(); |
| 412 | 413 |
| 413 if (list.size() != otherList.size()) | 414 if (list.size() != otherList.size()) |
| 414 return false; | 415 return false; |
| 415 | 416 |
| 416 for (size_t i = 0; i < list.size(); i++) { | 417 for (size_t i = 0; i < list.size(); i++) { |
| 417 if (list[i]->contents() != otherList[i]->contents()) | 418 if (list[i]->contents() != otherList[i]->contents()) |
| 418 return false; | 419 return false; |
| 419 } | 420 } |
| 420 | 421 |
| 421 return true; | 422 return true; |
| 422 } | 423 } |
| 423 | 424 |
| 424 } // namespace blink | 425 } // namespace blink |
| OLD | NEW |