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

Side by Side Diff: Source/core/css/MediaList.h

Issue 15094019: Fixing inconsistency with Media Query append/deleteMedium. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 7 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 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights reserv ed.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 static PassRefPtr<MediaQuerySet> create(const String& mediaString) 45 static PassRefPtr<MediaQuerySet> create(const String& mediaString)
46 { 46 {
47 return adoptRef(new MediaQuerySet(mediaString, false)); 47 return adoptRef(new MediaQuerySet(mediaString, false));
48 } 48 }
49 static PassRefPtr<MediaQuerySet> createAllowingDescriptionSyntax(const Strin g& mediaString) 49 static PassRefPtr<MediaQuerySet> createAllowingDescriptionSyntax(const Strin g& mediaString)
50 { 50 {
51 return adoptRef(new MediaQuerySet(mediaString, true)); 51 return adoptRef(new MediaQuerySet(mediaString, true));
52 } 52 }
53 ~MediaQuerySet(); 53 ~MediaQuerySet();
54 54
55 bool parse(const String&); 55 bool set(const String&);
56 bool add(const String&); 56 bool add(const String&);
57 bool remove(const String&); 57 bool remove(const String&);
58 58
59 void addMediaQuery(PassOwnPtr<MediaQuery>); 59 void addMediaQuery(PassOwnPtr<MediaQuery>);
60 60
61 const Vector<OwnPtr<MediaQuery> >& queryVector() const { return m_queries; } 61 const Vector<OwnPtr<MediaQuery> >& queryVector() const { return m_queries; }
62 62
63 int lastLine() const { return m_lastLine; } 63 int lastLine() const { return m_lastLine; }
64 void setLastLine(int lastLine) { m_lastLine = lastLine; } 64 void setLastLine(int lastLine) { m_lastLine = lastLine; }
65 65
66 String mediaText() const; 66 String mediaText() const;
67 67
68 PassRefPtr<MediaQuerySet> copy() const { return adoptRef(new MediaQuerySet(* this)); } 68 PassRefPtr<MediaQuerySet> copy() const { return adoptRef(new MediaQuerySet(* this)); }
69 69
70 void reportMemoryUsage(MemoryObjectInfo*) const; 70 void reportMemoryUsage(MemoryObjectInfo*) const;
71 71
72 private: 72 private:
73 MediaQuerySet(); 73 MediaQuerySet();
74 MediaQuerySet(const String& mediaQuery, bool fallbackToDescription); 74 MediaQuerySet(const String& mediaQuery, bool fallbackToDescription);
75 MediaQuerySet(const MediaQuerySet&); 75 MediaQuerySet(const MediaQuerySet&);
76 76
77 PassOwnPtr<MediaQuery> parseMediaQuery(const String&); 77 PassOwnPtr<MediaQuery> parseMediaQuery(const String&);
78 void parseMediaQueryList(const String&, Vector<OwnPtr<MediaQuery> >& result) ;
78 79
79 unsigned m_fallbackToDescriptor : 1; // true if failed media query parsing s hould fallback to media description parsing. 80 unsigned m_fallbackToDescriptor : 1; // true if failed media query parsing s hould fallback to media description parsing.
80 signed m_lastLine : 31; 81 unsigned m_lastLine : 31;
81 Vector<OwnPtr<MediaQuery> > m_queries; 82 Vector<OwnPtr<MediaQuery> > m_queries;
82 }; 83 };
83 84
84 class MediaList : public RefCounted<MediaList> { 85 class MediaList : public RefCounted<MediaList> {
85 public: 86 public:
86 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSStyleShe et* parentSheet) 87 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSStyleShe et* parentSheet)
87 { 88 {
88 return adoptRef(new MediaList(mediaQueries, parentSheet)); 89 return adoptRef(new MediaList(mediaQueries, parentSheet));
89 } 90 }
90 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSRule* pa rentRule) 91 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSRule* pa rentRule)
91 { 92 {
92 return adoptRef(new MediaList(mediaQueries, parentRule)); 93 return adoptRef(new MediaList(mediaQueries, parentRule));
93 } 94 }
94 95
95 ~MediaList(); 96 ~MediaList();
96 97
97 unsigned length() const { return m_mediaQueries->queryVector().size(); } 98 unsigned length() const { return m_mediaQueries->queryVector().size(); }
98 String item(unsigned index) const; 99 String item(unsigned index) const;
99 void deleteMedium(const String& oldMedium, ExceptionCode&); 100 void deleteMedium(const String& oldMedium, ExceptionCode&);
100 void appendMedium(const String& newMedium, ExceptionCode&); 101 void appendMedium(const String& newMedium, ExceptionCode&);
101 102
102 String mediaText() const { return m_mediaQueries->mediaText(); } 103 String mediaText() const { return m_mediaQueries->mediaText(); }
103 void setMediaText(const String&, ExceptionCode&); 104 void setMediaText(const String&);
104 105
105 // Not part of CSSOM. 106 // Not part of CSSOM.
106 CSSRule* parentRule() const { return m_parentRule; } 107 CSSRule* parentRule() const { return m_parentRule; }
107 CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; } 108 CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; }
108 void clearParentStyleSheet() { ASSERT(m_parentStyleSheet); m_parentStyleShee t = 0; } 109 void clearParentStyleSheet() { ASSERT(m_parentStyleSheet); m_parentStyleShee t = 0; }
109 void clearParentRule() { ASSERT(m_parentRule); m_parentRule = 0; } 110 void clearParentRule() { ASSERT(m_parentRule); m_parentRule = 0; }
110 const MediaQuerySet* queries() const { return m_mediaQueries.get(); } 111 const MediaQuerySet* queries() const { return m_mediaQueries.get(); }
111 112
112 void reattach(MediaQuerySet*); 113 void reattach(MediaQuerySet*);
113 114
114 void reportMemoryUsage(MemoryObjectInfo*) const; 115 void reportMemoryUsage(MemoryObjectInfo*) const;
115 116
116 private: 117 private:
117 MediaList(); 118 MediaList();
118 MediaList(MediaQuerySet*, CSSStyleSheet* parentSheet); 119 MediaList(MediaQuerySet*, CSSStyleSheet* parentSheet);
119 MediaList(MediaQuerySet*, CSSRule* parentRule); 120 MediaList(MediaQuerySet*, CSSRule* parentRule);
120 121
121 RefPtr<MediaQuerySet> m_mediaQueries; 122 RefPtr<MediaQuerySet> m_mediaQueries;
122 CSSStyleSheet* m_parentStyleSheet; 123 CSSStyleSheet* m_parentStyleSheet;
123 CSSRule* m_parentRule; 124 CSSRule* m_parentRule;
124 }; 125 };
125 126
126 // Adds message to inspector console whenever dpi or dpcm values are used for "s creen" media. 127 // Adds message to inspector console whenever dpi or dpcm values are used for "s creen" media.
127 void reportMediaQueryWarningIfNeeded(Document*, const MediaQuerySet*); 128 void reportMediaQueryWarningIfNeeded(Document*, const MediaQuerySet*);
128 129
129 } // namespace 130 } // namespace
130 131
131 #endif 132 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698