Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: Source/core/rendering/style/RenderStyle.cpp

Issue 18371008: Add a WebDocument::watchCssSelectors(selectors) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@pinned
Patch Set: Fix most comments; TODO benchmark and use Element::recalcStyle Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 * 20 *
21 */ 21 */
22 22
23 #include "config.h" 23 #include "config.h"
24 #include "core/rendering/style/RenderStyle.h" 24 #include "core/rendering/style/RenderStyle.h"
25 25
26 #include <algorithm> 26 #include <algorithm>
27 #include "CSSPropertyNames.h" 27 #include "CSSPropertyNames.h"
28 #include "core/css/resolver/StyleResolver.h" 28 #include "core/css/resolver/StyleResolver.h"
29 #include "core/dom/CSSSelectorWatch.h"
29 #include "core/dom/WebCoreMemoryInstrumentation.h" 30 #include "core/dom/WebCoreMemoryInstrumentation.h"
30 #include "core/platform/graphics/Font.h" 31 #include "core/platform/graphics/Font.h"
31 #include "core/platform/graphics/FontSelector.h" 32 #include "core/platform/graphics/FontSelector.h"
32 #include "core/rendering/RenderTheme.h" 33 #include "core/rendering/RenderTheme.h"
33 #include "core/rendering/TextAutosizer.h" 34 #include "core/rendering/TextAutosizer.h"
34 #include "core/rendering/style/ContentData.h" 35 #include "core/rendering/style/ContentData.h"
35 #include "core/rendering/style/CursorList.h" 36 #include "core/rendering/style/CursorList.h"
36 #include "core/rendering/style/QuotesData.h" 37 #include "core/rendering/style/QuotesData.h"
37 #include "core/rendering/style/ShadowData.h" 38 #include "core/rendering/style/ShadowData.h"
38 #include "core/rendering/style/StyleImage.h" 39 #include "core/rendering/style/StyleImage.h"
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 return; 686 return;
686 rareInheritedData.access()->quotes = q; 687 rareInheritedData.access()->quotes = q;
687 } 688 }
688 689
689 void RenderStyle::clearCursorList() 690 void RenderStyle::clearCursorList()
690 { 691 {
691 if (rareInheritedData->cursorData) 692 if (rareInheritedData->cursorData)
692 rareInheritedData.access()->cursorData = 0; 693 rareInheritedData.access()->cursorData = 0;
693 } 694 }
694 695
696 void RenderStyle::addCallbackSelector(const String& selector, CSSSelectorWatch* selectorWatch)
697 {
698 ASSERT(!rareNonInheritedData->m_selectorWatch.get()
699 || rareNonInheritedData->m_selectorWatch.get() == selectorWatch);
700 if (!rareNonInheritedData->m_callbackSelectors.contains(selector)) {
701 StyleRareNonInheritedData* data = rareNonInheritedData.access();
702 data->m_callbackSelectors.append(selector);
703 // Assigns a WeakPtr to |selectorWatch| to data->m_selectorWatch.
704 selectorWatch->addSelectorMatch(selector, data);
705 }
706 }
707
708 void RenderStyle::removeCallbackSelector(const String& selector)
esprehn 2013/07/17 07:14:32 Nothing ever calls this, can you just remove it?
Jeffrey Yasskin 2013/08/02 01:34:07 Done.
709 {
710 size_t index = rareNonInheritedData->m_callbackSelectors.find(selector);
711 if (index != notFound) {
712 rareNonInheritedData.access()->m_callbackSelectors.remove(index);
713 if (CSSSelectorWatch* selectorWatch = rareNonInheritedData->m_selectorWa tch.get())
714 selectorWatch->removeSelectorMatch(selector);
715 }
716 }
717
695 void RenderStyle::clearContent() 718 void RenderStyle::clearContent()
696 { 719 {
697 if (rareNonInheritedData->m_content) 720 if (rareNonInheritedData->m_content)
698 rareNonInheritedData.access()->m_content = nullptr; 721 rareNonInheritedData.access()->m_content = nullptr;
699 } 722 }
700 723
701 void RenderStyle::appendContent(PassOwnPtr<ContentData> contentData) 724 void RenderStyle::appendContent(PassOwnPtr<ContentData> contentData)
702 { 725 {
703 OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content; 726 OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content;
704 ContentData* lastContent = content.get(); 727 ContentData* lastContent = content.get();
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 info.addMember(rareInheritedData, "rareInheritedData"); 1596 info.addMember(rareInheritedData, "rareInheritedData");
1574 // FIXME: inherited contains StyleImage and Font fields that might need to b e instrumented. 1597 // FIXME: inherited contains StyleImage and Font fields that might need to b e instrumented.
1575 info.addMember(inherited, "inherited"); 1598 info.addMember(inherited, "inherited");
1576 info.addMember(m_cachedPseudoStyles, "cachedPseudoStyles"); 1599 info.addMember(m_cachedPseudoStyles, "cachedPseudoStyles");
1577 info.addMember(m_svgStyle, "svgStyle"); 1600 info.addMember(m_svgStyle, "svgStyle");
1578 info.addMember(inherited_flags, "inherited_flags"); 1601 info.addMember(inherited_flags, "inherited_flags");
1579 info.addMember(noninherited_flags, "noninherited_flags"); 1602 info.addMember(noninherited_flags, "noninherited_flags");
1580 } 1603 }
1581 1604
1582 } // namespace WebCore 1605 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698