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

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, 6 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 18 matching lines...) Expand all
29 #include "wtf/text/WTFString.h" 29 #include "wtf/text/WTFString.h"
30 30
31 namespace WebCore { 31 namespace WebCore {
32 32
33 class CSSRule; 33 class CSSRule;
34 class CSSStyleSheet; 34 class CSSStyleSheet;
35 class Document; 35 class Document;
36 class MediaList; 36 class MediaList;
37 class MediaQuery; 37 class MediaQuery;
38 38
39 enum MediaQueryParserMode {
40 MediaQueryNormalMode,
41 MediaQueryForwardCompatibleSyntaxMode,
42 MediaQueryStrictMode,
43 };
44
39 class MediaQuerySet : public RefCounted<MediaQuerySet> { 45 class MediaQuerySet : public RefCounted<MediaQuerySet> {
40 public: 46 public:
41 static PassRefPtr<MediaQuerySet> create() 47 static PassRefPtr<MediaQuerySet> create()
42 { 48 {
43 return adoptRef(new MediaQuerySet()); 49 return adoptRef(new MediaQuerySet());
44 } 50 }
45 static PassRefPtr<MediaQuerySet> create(const String& mediaString) 51 static PassRefPtr<MediaQuerySet> create(const String& mediaString)
46 { 52 {
47 return adoptRef(new MediaQuerySet(mediaString, false)); 53 return adoptRef(new MediaQuerySet(mediaString, MediaQueryNormalMode));
48 } 54 }
49 static PassRefPtr<MediaQuerySet> createAllowingDescriptionSyntax(const Strin g& mediaString) 55 static PassRefPtr<MediaQuerySet> createAllowingDescriptionSyntax(const Strin g& mediaString)
50 { 56 {
51 return adoptRef(new MediaQuerySet(mediaString, true)); 57 return adoptRef(new MediaQuerySet(mediaString, MediaQueryForwardCompatib leSyntaxMode));
52 } 58 }
53 ~MediaQuerySet(); 59 ~MediaQuerySet();
54 60
55 bool parse(const String&); 61 bool set(const String&);
56 bool add(const String&); 62 bool add(const String&);
57 bool remove(const String&); 63 bool remove(const String&);
58 64
59 void addMediaQuery(PassOwnPtr<MediaQuery>); 65 void addMediaQuery(PassOwnPtr<MediaQuery>);
60 66
61 const Vector<OwnPtr<MediaQuery> >& queryVector() const { return m_queries; } 67 const Vector<OwnPtr<MediaQuery> >& queryVector() const { return m_queries; }
62 68
63 int lastLine() const { return m_lastLine; } 69 int lastLine() const { return m_lastLine; }
64 void setLastLine(int lastLine) { m_lastLine = lastLine; } 70 void setLastLine(int lastLine) { m_lastLine = lastLine; }
65 71
66 String mediaText() const; 72 String mediaText() const;
67 73
68 PassRefPtr<MediaQuerySet> copy() const { return adoptRef(new MediaQuerySet(* this)); } 74 PassRefPtr<MediaQuerySet> copy() const { return adoptRef(new MediaQuerySet(* this)); }
69 75
70 void reportMemoryUsage(MemoryObjectInfo*) const; 76 void reportMemoryUsage(MemoryObjectInfo*) const;
71 77
72 private: 78 private:
73 MediaQuerySet(); 79 MediaQuerySet();
74 MediaQuerySet(const String& mediaQuery, bool fallbackToDescription); 80 MediaQuerySet(const String& mediaQuery, MediaQueryParserMode);
75 MediaQuerySet(const MediaQuerySet&); 81 MediaQuerySet(const MediaQuerySet&);
76 82
77 PassOwnPtr<MediaQuery> parseMediaQuery(const String&); 83 PassOwnPtr<MediaQuery> parseMediaQuery(const String&, MediaQueryParserMode);
84 void parseMediaQueryList(const String&, MediaQueryParserMode, Vector<OwnPtr< MediaQuery> >& result);
78 85
79 unsigned m_fallbackToDescriptor : 1; // true if failed media query parsing s hould fallback to media description parsing. 86 MediaQueryParserMode m_parserMode;
apavlov 2013/05/29 15:44:36 Should this occupy 2 bits, and m_lastLine (added b
kenneth.r.christiansen 2013/05/29 15:52:56 Sounds fine. Let me do that change
80 signed m_lastLine : 31; 87 unsigned m_lastLine : 31;
81 Vector<OwnPtr<MediaQuery> > m_queries; 88 Vector<OwnPtr<MediaQuery> > m_queries;
82 }; 89 };
83 90
84 class MediaList : public RefCounted<MediaList> { 91 class MediaList : public RefCounted<MediaList> {
85 public: 92 public:
86 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSStyleShe et* parentSheet) 93 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSStyleShe et* parentSheet)
87 { 94 {
88 return adoptRef(new MediaList(mediaQueries, parentSheet)); 95 return adoptRef(new MediaList(mediaQueries, parentSheet));
89 } 96 }
90 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSRule* pa rentRule) 97 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSRule* pa rentRule)
91 { 98 {
92 return adoptRef(new MediaList(mediaQueries, parentRule)); 99 return adoptRef(new MediaList(mediaQueries, parentRule));
93 } 100 }
94 101
95 ~MediaList(); 102 ~MediaList();
96 103
97 unsigned length() const { return m_mediaQueries->queryVector().size(); } 104 unsigned length() const { return m_mediaQueries->queryVector().size(); }
98 String item(unsigned index) const; 105 String item(unsigned index) const;
99 void deleteMedium(const String& oldMedium, ExceptionCode&); 106 void deleteMedium(const String& oldMedium, ExceptionCode&);
100 void appendMedium(const String& newMedium, ExceptionCode&); 107 void appendMedium(const String& newMedium, ExceptionCode&);
101 108
102 String mediaText() const { return m_mediaQueries->mediaText(); } 109 String mediaText() const { return m_mediaQueries->mediaText(); }
103 void setMediaText(const String&, ExceptionCode&); 110 void setMediaText(const String&);
104 111
105 // Not part of CSSOM. 112 // Not part of CSSOM.
106 CSSRule* parentRule() const { return m_parentRule; } 113 CSSRule* parentRule() const { return m_parentRule; }
107 CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; } 114 CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; }
108 void clearParentStyleSheet() { ASSERT(m_parentStyleSheet); m_parentStyleShee t = 0; } 115 void clearParentStyleSheet() { ASSERT(m_parentStyleSheet); m_parentStyleShee t = 0; }
109 void clearParentRule() { ASSERT(m_parentRule); m_parentRule = 0; } 116 void clearParentRule() { ASSERT(m_parentRule); m_parentRule = 0; }
110 const MediaQuerySet* queries() const { return m_mediaQueries.get(); } 117 const MediaQuerySet* queries() const { return m_mediaQueries.get(); }
111 118
112 void reattach(MediaQuerySet*); 119 void reattach(MediaQuerySet*);
113 120
114 void reportMemoryUsage(MemoryObjectInfo*) const; 121 void reportMemoryUsage(MemoryObjectInfo*) const;
115 122
116 private: 123 private:
117 MediaList(); 124 MediaList();
118 MediaList(MediaQuerySet*, CSSStyleSheet* parentSheet); 125 MediaList(MediaQuerySet*, CSSStyleSheet* parentSheet);
119 MediaList(MediaQuerySet*, CSSRule* parentRule); 126 MediaList(MediaQuerySet*, CSSRule* parentRule);
120 127
121 RefPtr<MediaQuerySet> m_mediaQueries; 128 RefPtr<MediaQuerySet> m_mediaQueries;
122 CSSStyleSheet* m_parentStyleSheet; 129 CSSStyleSheet* m_parentStyleSheet;
123 CSSRule* m_parentRule; 130 CSSRule* m_parentRule;
124 }; 131 };
125 132
126 // Adds message to inspector console whenever dpi or dpcm values are used for "s creen" media. 133 // Adds message to inspector console whenever dpi or dpcm values are used for "s creen" media.
127 void reportMediaQueryWarningIfNeeded(Document*, const MediaQuerySet*); 134 void reportMediaQueryWarningIfNeeded(Document*, const MediaQuerySet*);
128 135
129 } // namespace 136 } // namespace
130 137
131 #endif 138 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698