~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/rendering/HitTestResult.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include "HTMLAnchorElement.h"
27
27
#include "HTMLImageElement.h"
28
28
#include "HTMLInputElement.h"
 
29
#include "HTMLMediaElement.h"
29
30
#include "HTMLNames.h"
30
31
#include "RenderImage.h"
31
32
#include "Scrollbar.h"
145
146
    return frame->selection()->contains(m_point);
146
147
}
147
148
 
148
 
String HitTestResult::spellingToolTip() const
 
149
String HitTestResult::spellingToolTip(TextDirection& dir) const
149
150
{
 
151
    dir = LTR;
150
152
    // Return the tool tip string associated with this point, if any. Only markers associated with bad grammar
151
153
    // currently supply strings, but maybe someday markers associated with misspelled words will also.
152
154
    if (!m_innerNonSharedNode)
153
155
        return String();
154
156
    
155
 
     DocumentMarker* marker = m_innerNonSharedNode->document()->markerContainingPoint(m_point, DocumentMarker::Grammar);
 
157
    DocumentMarker* marker = m_innerNonSharedNode->document()->markerContainingPoint(m_point, DocumentMarker::Grammar);
156
158
    if (!marker)
157
159
        return String();
158
160
 
 
161
    if (RenderObject* renderer = m_innerNonSharedNode->renderer())
 
162
        dir = renderer->style()->direction();
159
163
    return marker->description;
160
164
}
161
165
 
162
 
String HitTestResult::title() const
163
 
{
 
166
String HitTestResult::replacedString() const
 
167
{
 
168
    // Return the replaced string associated with this point, if any. This marker is created when a string is autocorrected, 
 
169
    // and is used for generating a contextual menu item that allows it to easily be changed back if desired.
 
170
    if (!m_innerNonSharedNode)
 
171
        return String();
 
172
    
 
173
    DocumentMarker* marker = m_innerNonSharedNode->document()->markerContainingPoint(m_point, DocumentMarker::Replacement);
 
174
    if (!marker)
 
175
        return String();
 
176
    
 
177
    return marker->description;
 
178
}    
 
179
    
 
180
String HitTestResult::title(TextDirection& dir) const
 
181
{
 
182
    dir = LTR;
164
183
    // Find the title in the nearest enclosing DOM node.
165
184
    // For <area> tags in image maps, walk the tree for the <area>, not the <img> using it.
166
185
    for (Node* titleNode = m_innerNode.get(); titleNode; titleNode = titleNode->parentNode()) {
167
186
        if (titleNode->isElementNode()) {
168
187
            String title = static_cast<Element*>(titleNode)->title();
169
 
            if (!title.isEmpty())
 
188
            if (!title.isEmpty()) {
 
189
                if (RenderObject* renderer = titleNode->renderer())
 
190
                    dir = renderer->style()->direction();
170
191
                return title;
 
192
            }
171
193
        }
172
194
    }
173
195
    return String();
177
199
{
178
200
    if (!node)
179
201
        return string;
180
 
    String copy(string);
181
 
    copy.replace('\\', node->document()->backslashAsCurrencySymbol());
182
 
    return copy;
 
202
    return node->document()->displayStringModifiedByEncoding(string);
183
203
}
184
204
 
185
205
String HitTestResult::altDisplayString() const
189
209
    
190
210
    if (m_innerNonSharedNode->hasTagName(imgTag)) {
191
211
        HTMLImageElement* image = static_cast<HTMLImageElement*>(m_innerNonSharedNode.get());
192
 
        return displayString(image->alt(), m_innerNonSharedNode.get());
 
212
        return displayString(image->getAttribute(altAttr), m_innerNonSharedNode.get());
193
213
    }
194
214
    
195
215
    if (m_innerNonSharedNode->hasTagName(inputTag)) {
196
216
        HTMLInputElement* input = static_cast<HTMLInputElement*>(m_innerNonSharedNode.get());
197
217
        return displayString(input->alt(), m_innerNonSharedNode.get());
198
218
    }
199
 
    
 
219
 
200
220
#if ENABLE(WML)
201
221
    if (m_innerNonSharedNode->hasTagName(WMLNames::imgTag)) {
202
222
        WMLImageElement* image = static_cast<WMLImageElement*>(m_innerNonSharedNode.get());
226
246
{
227
247
    if (!image())
228
248
        return IntRect();
229
 
    return m_innerNonSharedNode->renderer()->absoluteContentBox();
 
249
    return m_innerNonSharedNode->renderBox()->absoluteContentBox();
230
250
}
231
251
 
232
252
KURL HitTestResult::absoluteImageURL() const
254
274
    } else
255
275
        return KURL();
256
276
 
257
 
    return m_innerNonSharedNode->document()->completeURL(parseURL(urlString));
 
277
    return m_innerNonSharedNode->document()->completeURL(deprecatedParseURL(urlString));
 
278
}
 
279
 
 
280
KURL HitTestResult::absoluteMediaURL() const
 
281
{
 
282
#if ENABLE(VIDEO)
 
283
    if (!(m_innerNonSharedNode && m_innerNonSharedNode->document()))
 
284
        return KURL();
 
285
 
 
286
    if (!(m_innerNonSharedNode->renderer() && m_innerNonSharedNode->renderer()->isMedia()))
 
287
        return KURL();
 
288
 
 
289
    AtomicString urlString;
 
290
    if (m_innerNonSharedNode->hasTagName(HTMLNames::videoTag) || m_innerNonSharedNode->hasTagName(HTMLNames::audioTag)) {
 
291
        HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(m_innerNonSharedNode.get());
 
292
        urlString = mediaElement->currentSrc();
 
293
    } else
 
294
        return KURL();
 
295
 
 
296
    return m_innerNonSharedNode->document()->completeURL(deprecatedParseURL(urlString));
 
297
#else
 
298
    return KURL();
 
299
#endif
258
300
}
259
301
 
260
302
KURL HitTestResult::absoluteLinkURL() const
276
318
    else
277
319
        return KURL();
278
320
 
279
 
    return m_innerURLElement->document()->completeURL(parseURL(urlString));
 
321
    return m_innerURLElement->document()->completeURL(deprecatedParseURL(urlString));
280
322
}
281
323
 
282
324
bool HitTestResult::isLiveLink() const