Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1d72655

Browse filesBrowse files
committed
refactor: hash renamed to the fragment
1 parent 960d611 commit 1d72655
Copy full SHA for 1d72655

File tree

Expand file treeCollapse file tree

4 files changed

+28
-28
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+28
-28
lines changed

‎support/gtkmm4/html_widget.cpp

Copy file name to clipboardExpand all lines: support/gtkmm4/html_widget.cpp
+14-14Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ cairo_surface_t *html_widget::load_image(const std::string &path)
180180

181181
}
182182

183-
void html_widget::open_page(const litehtml::string& url, const litehtml::string& hash)
183+
void html_widget::open_page(const litehtml::string& url, const litehtml::string& fragment)
184184
{
185185
{
186186
std::lock_guard<std::mutex> lock(m_page_mutex);
@@ -189,7 +189,7 @@ void html_widget::open_page(const litehtml::string& url, const litehtml::string&
189189
m_current_page->stop_loading();
190190
}
191191
m_next_page = std::make_shared<litebrowser::web_page>(this, m_notifier, 10);
192-
m_next_page->open(url, hash);
192+
m_next_page->open(url, fragment);
193193
}
194194
m_sig_set_address.emit(url);
195195
m_sig_update_state.emit(get_state());
@@ -619,37 +619,37 @@ void html_widget::on_page_loaded(uint64_t web_page_id)
619619
m_sig_update_state.emit(get_state());
620620
}
621621

622-
void html_widget::show_hash(const std::string &hash)
622+
void html_widget::show_fragment(const std::string &fragment)
623623
{
624624
std::shared_ptr<litebrowser::web_page> page = current_page();
625625
if(page)
626626
{
627-
page->show_hash(hash);
627+
page->show_fragment(fragment);
628628
}
629629
}
630630

631631
void html_widget::open_url(const std::string &url)
632632
{
633-
std::string hash;
633+
std::string fragment;
634634
std::string s_url = url;
635635

636636
m_sig_set_address.emit(url);
637637

638-
std::string::size_type hash_pos = s_url.find_first_of(L'#');
639-
if(hash_pos != std::wstring::npos)
638+
std::string::size_type fragment_pos = s_url.find_first_of(L'#');
639+
if(fragment_pos != std::wstring::npos)
640640
{
641-
hash = s_url.substr(hash_pos + 1);
642-
s_url.erase(hash_pos);
641+
fragment = s_url.substr(fragment_pos + 1);
642+
s_url.erase(fragment_pos);
643643
}
644644

645645
bool open_hash_only = false;
646646
bool reload = false;
647647

648648
auto current_url = m_history.current();
649-
hash_pos = current_url.find_first_of(L'#');
650-
if(hash_pos != std::wstring::npos)
649+
fragment_pos = current_url.find_first_of(L'#');
650+
if(fragment_pos != std::wstring::npos)
651651
{
652-
current_url.erase(hash_pos);
652+
current_url.erase(fragment_pos);
653653
}
654654

655655
if(!current_url.empty())
@@ -667,10 +667,10 @@ void html_widget::open_url(const std::string &url)
667667
}
668668
if(!open_hash_only)
669669
{
670-
open_page(url, hash);
670+
open_page(url, fragment);
671671
} else
672672
{
673-
show_hash(hash);
673+
show_fragment(fragment);
674674
}
675675
if(!reload)
676676
{

‎support/gtkmm4/html_widget.h

Copy file name to clipboardExpand all lines: support/gtkmm4/html_widget.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class html_widget : public Gtk::Widget,
235235
std::string get_html_source();
236236
long render_measure(int number);
237237
long draw_measure(int number);
238-
void show_hash(const std::string& hash);
238+
void show_fragment(const std::string& fragment);
239239
bool on_close();
240240
void dump(litehtml::dumper& cout);
241241

@@ -246,7 +246,7 @@ class html_widget : public Gtk::Widget,
246246
double get_dpi() override;
247247
int get_screen_width() override;
248248
int get_screen_height() override;
249-
void open_page(const litehtml::string& url, const litehtml::string& hash);
249+
void open_page(const litehtml::string& url, const litehtml::string& fragment);
250250
void update_cursor() override;
251251
void redraw_boxes(const litehtml::position::vector& boxes) override;
252252
int get_render_width() override;

‎support/webpage/web_page.cpp

Copy file name to clipboardExpand all lines: support/webpage/web_page.cpp
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void litebrowser::text_file::on_page_downloaded(u_int32_t http_status,
2121
wait_mutex.unlock();
2222
}
2323

24-
void litebrowser::web_page::open(const std::string &url, const std::string &hash)
24+
void litebrowser::web_page::open(const std::string &url, const std::string &fragment)
2525
{
2626
litehtml::url l_url(url);
2727

@@ -39,7 +39,7 @@ void litebrowser::web_page::open(const std::string &url, const std::string &hash
3939
m_url = url;
4040
}
4141
m_base_url = m_url;
42-
m_hash = hash;
42+
m_fragment = fragment;
4343

4444
auto data = std::make_shared<text_file>();
4545
auto cb_on_data = [data](auto && PH1, auto && PH2, auto && PH3, auto && PH4) mutable { data->on_data(std::forward<decltype(PH1)>(PH1), std::forward<decltype(PH2)>(PH2), std::forward<decltype(PH3)>(PH3), std::forward<decltype(PH4)>(PH4)); };
@@ -110,15 +110,15 @@ cairo_surface_t* litebrowser::web_page::get_image(const std::string& url)
110110
return m_images.get_image(url);
111111
}
112112

113-
void litebrowser::web_page::show_hash(const litehtml::string& hash)
113+
void litebrowser::web_page::show_fragment(const litehtml::string& fragment)
114114
{
115115
std::lock_guard<std::recursive_mutex> html_lock(m_html_mutex);
116-
if(hash.empty() || !m_html)
116+
if(fragment.empty() || !m_html)
117117
{
118118
m_html_host->scroll_to(0, 0);
119119
} else
120120
{
121-
auto escaped_hash = litehtml::get_escaped_string(hash);
121+
auto escaped_hash = litehtml::get_escaped_string(fragment);
122122
std::string selector = ":is([id=\"" + escaped_hash + "\"],[name=\"" + escaped_hash + "\"])";
123123
litehtml::element::ptr el = m_html->root()->select_one(selector);
124124
if (el)

‎support/webpage/web_page.h

Copy file name to clipboardExpand all lines: support/webpage/web_page.h
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ namespace litebrowser
6868
std::recursive_mutex m_html_mutex;
6969
litehtml::string m_cursor;
7070
litehtml::string m_clicked_url;
71-
std::string m_hash;
71+
std::string m_fragment;
7272
html_host_interface* m_html_host;
7373
cairo_images_cache m_images;
7474
litebrowser::http_requests_pool m_requests_pool;
@@ -89,7 +89,7 @@ namespace litebrowser
8989
[[nodiscard]]
9090
const std::string& get_html_source() const { return m_html_source; }
9191

92-
void open(const litehtml::string& url, const litehtml::string& hash);
92+
void open(const litehtml::string& url, const litehtml::string& fragment);
9393

9494
void get_viewport(litehtml::position& viewport) const override;
9595
void on_anchor_click(const char* url, const litehtml::element::ptr& el) override;
@@ -105,13 +105,13 @@ namespace litebrowser
105105
int get_screen_width() const override;
106106
int get_screen_height() const override;
107107

108-
void show_hash(const litehtml::string& hash);
109-
void show_hash_and_reset()
108+
void show_fragment(const litehtml::string& fragment);
109+
void show_fragment_and_reset()
110110
{
111-
if(!m_hash.empty() && m_html)
111+
if(!m_fragment.empty() && m_html)
112112
{
113-
show_hash(m_hash);
114-
m_hash = "";
113+
show_fragment(m_fragment);
114+
m_fragment = "";
115115
}
116116
}
117117

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.